Hi Paul,

Thank-you for taking the time to look at this and explain it clearly. I have 
now found the reference you mentioned in the Help...

Excel has a bunch of "interesting" features.

Regards - Dave. 


Date: Mon, 21 Dec 2009 06:03:03 -0800
From: schreiner_p...@att.net
Subject: Re: $$Excel-Macros$$ Named ranges in macros
To: excel-macros@googlegroups.com





"I can't fine any reference to this style of notation in the Help":
 
try searching for:
"use ["
or:
"Refer to Cells by Using Shortcut Notation"
 

It says: 

"You can use either the A1 reference style or a named 

range within brackets as a shortcut for the Range property.

 You do not have to type the word "Range" or use quotation marks"

=======================================

as to the phenomenon:

It's acting as *I* would expect it to.

First of all, unless told otherwise, the Range object

refers to the activesheet.

the Wizards of Microsoft were nice enough to allow us to

NOT always specify the currently Active sheet.

 

In a SHEET macro (one defined in the Sheet Module)

Notice you're starting out with "Private"

and "WorkSHEET"_Activate.

this tells me that we're already working with

stuff related to THIS SHEET ONLY.

so the "assumption" when you specify a range, it is for the current sheet.

so, again, with the sheet macro, it assumes that the named

range is on the currently active sheet.

 

the curious part is that the range shortcut of "[]" does NOT

assume the currently active sheet, and therefore

looks to the Name manager to determine the source.

 

I also noticed that if you create the named range as

related to the "Sheet" instead of the "workbook", the

shortcut version of the Range Object works as it normally does.

using [] for a Sheet defined named range does not work

if you're in another sheet.

 

interesting...

 

Paul

 





From: Dave Bonallack <davebonall...@hotmail.com>
To: "excel-macros@googlegroups.com" <excel-macros@googlegroups.com>
Sent: Mon, December 21, 2009 12:00:41 AM
Subject: $$Excel-Macros$$ Named ranges in macros



Hi XL'ers
I am using XL2003
This is a follow-on from a previous post.
 
I refer to the use of the following (meaningless) Worksheet Window macro:
 
Private Sub Worksheet_Activate()
With Range("CompNames")
End With
End Sub
 
If the named range (CompNames) is on the sheet being actived, the code runs ok.
If the named range is not on the sheet being activated, I get the following 
error:
 
Runtime error '1004'
Application-defined or object-defined error
 
If the 2 code lines are put into normal macro in a module, the error does not 
occur.
I have discovered that I can get around this by using:
 
Private Sub Worksheet_Activate()
With [CompNames]
End With
End Sub
 
But I can't find any reference to this style of notation in the Help. Someone 
in this group mentioned it, and I tried it out of desperation.
Has anyone else had this problem, or can anyone else confirm that this is so? 
It's been driving me nuts.
 
Regards - Dave.



Find out how Use Messenger in your Hotmail inbox 

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com

 
To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!
 
We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com

 
To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!
 
We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe                           
           
_________________________________________________________________
Get more out of Hotmail Check out the latest features today
http://windowslive.ninemsn.com.au/hotmail/article/878466/your-hotmail-is-about-to-get-even-better

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

Reply via email to