Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Static variable
Hi, In one sub Im using a static variable to keep count. With this Im
using a timer to run through the macro at certain intervals. On a userform I use 2 command buttons, one to start the timer and another to stop the timer. This all works well apart from when I stop the timer, then restart my Static continues from its last count. In the sub with the static variable I can use 'Erase whatever'. Because the Stop command does not execute that sub, is there a way to globally clear the static variable without closing the workbook. Regards Robert |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Static variable
Hi
You could change the static variable to a public variable (declared in a general code module outside of any subs and not in something like Sheet1). It should have much the same functionality as static (preserving values between calls unless the project is reset) with the added advantage that any sub can change its value - so you're userform subs would be able to change it as well. HTH -John Coleman On Jan 28, 4:21 am, "RobcPettit" wrote: Hi, In one sub Im using a static variable to keep count. With this Im using a timer to run through the macro at certain intervals. On a userform I use 2 command buttons, one to start the timer and another to stop the timer. This all works well apart from when I stop the timer, then restart my Static continues from its last count. In the sub with the static variable I can use 'Erase whatever'. Because the Stop command does not execute that sub, is there a way to globally clear the static variable without closing the workbook. Regards Robert |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
STATIC VARIABLE NOT AVAILABLE IN ANOTHER MODULE | Excel Discussion (Misc queries) | |||
Static variable | Excel Programming | |||
NOT static variable problem | Excel Programming | |||
Static Variable | Excel Programming |