Unfortunately I don't understand how error handling applies since I'm
not generating an error and I can't make a parallel in your code to
my situation. I'm not to that kind of error handling either, so it
is foreign to me.
However, I found the doEvents function which seems to almost work for
me. The explanation on MSDN says it can be used to do a premature
Sub exit on an event. Unfortunately, I didn't bring the partially
working code with me
As we know, when you check a checkBox, this causes an event
which "fires" (jumps to) a subroutine (also an object) in that
sheet. While that sub is executing, it appears that no other events
are recognized. (actually, this sub calls a Sub in another module,
but the results are the same). event trapping appears to completely
stop. Therefore you can not click the check box, or any other check
boxes or Command Buttons to do anything. The Sub has to finish
normally before events are recognized again.
I did find doEvents which helps, but it is a bit eratic.
To figure out the code, THe event Sub calls a Sub with a While loop
which runs While the check box value is true. It continually prints
numbers with a debug.Print. The doEvents is in this loop.
Then I try to force it to quit by either "unChecking" the original
check box (thus setting its value to False) or using a command button
to set the CheckBox.Value to False. Both of these are working, but
about 30% of the time, it takes 2 or 3 clicks on either the box or
the button to exit the While Loop.
Do you think the event must occur while the doEvents function is
running and that's why it misses some? I was hoping to find a
command to resume event trapping while this sub was running so I
could manually force it to exit. What I need is a
ResumeEventCapture function. Some way to allow a button or check box
event to "register" on the conciousness of the darn VBA processor and
change that value...while the original, event.caused Sub is running.