Microsoft KB Archive/231089

= XL2000: Module-Level Variables Are Reset to Their Default Values =

Article ID: 231089

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q231089



SYMPTOMS
When you run a Microsoft Visual Basic for Applications macro (Sub procedure) for the second time from a workbook, both the public and private module-level variables in your macro are reset to their default settings.



CAUSE
This problem occurs when you do the following:
 * 1) You declare one or more variables using the Dim, Private, or Public keyword in the declaration section of a standard module.

-and-
 * 1) You write a Sub procedure in the same module and use the module-level variables.

-and-
 * 1) You click the Design Mode button on the Standard toolbar of the Visual Basic Editor, or on the Control Toolbox in Excel.

-and-
 * 1) You run the macro a second time.



WORKAROUND
To work around this problem, do not go into design mode until you no longer need to run your code.

