Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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- |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The End statement immediately clears all variables (and terminates macro
execution). -- Jim Rech Excel MVP |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. -- Regards, Rocky McKinley "TBA" wrote in message ... 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- |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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- "Rocky McKinley" wrote in message ... 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. -- Regards, Rocky McKinley "TBA" wrote in message ... 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- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Resetting Defaults | Setting up and Configuration of Excel | |||
Resetting cells | Excel Worksheet Functions | |||
Why are my options resetting themselves? | Excel Discussion (Misc queries) | |||
password resetting | Excel Discussion (Misc queries) | |||
Resetting the end of a worksheet | New Users to Excel |