Maintaining variables after program ends
If you stop the macro manually (usually while testing) by clicking the Reset
button (or Run|Reset from the menubar), then those public/static variables are
lost/reset to defaults.
If you use "End" to quit the macro (not "End Sub", "End If", "End Function",
....), then you'll reset those variables.
I'm gonna guess that you tried to quickly quit your code by using End and lost
the values your variables held.
Goody wrote:
My macro is triggered on Worksheet_Activate, and stores the contents of
several cells in an array. Later, when a button is clicked, another macro is
a standard module uses the variables in the array in a dialog box. It worked
for a while, but now, for some reason, as soon as the Worksheet_Activate
macro ends, the array values revert to Empty. I've tried declaring the array
in the worksheet code, the module code, and as Public, but nothing seems to
restore its earlier functionality. Where should the declaration be placed?
Goody
--
Dave Peterson
|