Resetting variables

  • Thread starter Thread starter TBA
  • Start date Start date
T

TBA

Is there a way to reset all variables in a macro? When I run it the first
time my results match my control results perfectly, but when I run it again
the numbers are all wrong.

TIA.

-gk-
 
If your variables are delcared with Dim in the sub then they should reset
when the routine ends.
If you declare them with Static then they will retain there values between
calls.
If your variables are delcared as Public at the top of a module they will
retain their values after code has ended and other procedures can see the
Public variable values also.

Variables declared using the Public statement are available to all
procedures in all modules in all applications unless Option Private Module
is in effect; in which case, the variables are public only within the
project in which they reside.
 
Ah, I believe I have a variable scope issue then. All my variables are
declared at the module level. Perhaps I need to move some of the
declarations inside the appropriate procedure?

-gk-
 
Back
Top