XL5: Name Defined Incorrectly If Sheet Name Contains SpaceLast reviewed: September 2, 1997Article ID: Q117125 |
The information in this article applies to:
SYMPTOMSIn 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.
CAUSEThis 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$1This defined name refers instead to the intersection of the ranges 'Sales' and 'SUMMARY!$A$1' instead of cell $A$1 on 'Sales Summary'.
STATUSMicrosoft 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.
WORKAROUNDTo 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).AddressNote 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$1This is the correct definition of the name.
|
Additional query words: 5.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |