XL97: Public Variables Are Not Seen on Modules for Sheet or UserForm (162971)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q162971 SYMPTOMS
If you declare a public variable on a Visual Basic for Applications code
module that is associated with an object, such as a UserForm or a Worksheet
object, only the procedures in the code module in which you declare the
variable can access the value the variable stores.
CAUSE
A variable that you declare with the Public statement in code modules that
are associated with an object, such as a UserForm and Worksheet object, is
available only to the module in which you declare it.
RESOLUTION
If you want to access a public variable in all procedures in all modules of
a project, declare the variable on a general module. To insert a general
module in a project, click Module on the Insert menu.
REFERENCES
For more information about the scope of variables, click the Office
Assistant in the Visual Basic Editor, type "scope," click Search, and then
click to view "Understanding Scope and Visibility."
NOTE: If the Assistant is hidden, click the Office Assistant button on the
Standard toolbar. If Visual Basic for Applications Help is not installed on
your computer, please see the following article in the Microsoft Knowledge
Base:
120802
Office: How to Add/Remove a Single Office
Program or Component
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbProgramming KB162971 |
---|
|