Article ID: 117125
Article Last Modified on 10/11/2006
Workbooks(BookName).Sheets(SheetName).Range(RangeName).Name =
"NameToDefine"
If you use this syntax to define a name, the name may be incorrectly
defined if the worksheet name contains a space. For example, if the
worksheet name is "Sales Summary" and the range to refer to is $A$1,
the name may be defined as
=Sales SUMMARY!$A$1This defined name refers instead to the intersection of the ranges 'Sales' and 'SUMMARY!$A$1' instead of cell $A$1 on 'Sales Summary'.
Workbooks(BookName).Names.Add Name:="NameToDefine",
RefersTo:="='" & Sheets(SheetName).Name & "'!" &
Sheets(SheetName).Range(RangeName).Address
Note the use of apostrophes (') in the RefersTo argument. These apostrophes
are included to ensure that the worksheet name is treated as a single name,
instead of as two words separated by a space.
='Sales Summary'!$A$1This is the correct definition of the name.
Additional query words: XL5
Keywords: kbprogramming KB117125