Name Defined Incorrectly If Sheet Name Contains Space (117125)
The information in this article applies to:
- Microsoft Excel for Windows 5.0
This article was previously published under Q117125 SYMPTOMS
In Microsoft Excel version 5.0, if you use a Visual Basic, Applications
Edition, subroutine to define a name on a worksheet and the name of the
worksheet contains a space, the name is not defined correctly.
CAUSE
This problem may occur if you use the following syntax to define a name:
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$1
This defined name refers instead to the intersection of the ranges 'Sales'
and 'SUMMARY!$A$1' instead of cell $A$1 on 'Sales Summary'.
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. This problem was corrected in
Microsoft Excel for Windows version 5.0c.
WORKAROUND
To avoid this problem, use the Names.Add syntax to define names in a
Visual Basic subroutine, as in the following example:
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.
Using the above example, the name would be defined as
='Sales Summary'!$A$1
This is the correct definition of the name.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbProgramming KB117125 |
---|
|