How to get looping VBA code to respond to events on worksheet
A quick way is to create a userform, with a button that sets the
g_paused = true
open the form show(vbmodeless)
then before your loop do
application.screenupdating = false
after your button is pressed
application.screenupdating = true.
"monkeyboy" wrote:
Hello,
I have some code of the form
do while not g_Paused
bunch of calls
...
loop
where I'd like the variable g_Paused to be toggled by a button on the
worksheet. The only way I can seem to get the code to respond to the
button click is to use
do while not g_Paused
bunch of calls
...
ThisWorkbook.Worksheets("Name").Activate
DoEvents
loop
But this is pretty slow and causes the sheet to flicker...is there a
better method?
PS
I'm using buttons from the Control Toolbox
Thank you.
|