View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ronald R. Dodge, Jr.[_2_] Ronald R. Dodge, Jr.[_2_] is offline
external usenet poster
 
Posts: 134
Default Stop all macros in worksheet when left

I'm assuming you have the time portion set to a variable that is accessible
to the Worksheet's Code Module.

You have one procedure that schedules the next time another procedure within
the module is ran. You then set the Deactivate Event within the Worksheet's
Code Module ("Worksheet" in the left combo-box and "Deactivate" in the right
combo-box just above the code module) to run the command that unschedules
the next run time.

Example code line within the Deactivate Event

Application.OnTime m_dteNextRunTime, "pcdReoccuringProcedure", , False

To get it back going again when the worksheet becomes active again, you just
use the Activate Event, set the Date/Time variable accordingly, and then use
the OnTime method to get it a going again.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"dgold82" wrote in message
...
Is there code that I can put in a worksheet module that automatically
stops
all the running macros when a user leaves that worksheet? My problem is
that
I have a timer macro that runs and if a user leaves that worksheet before
it
completely counts down then the screen becomes all garbled until the macro
is
stopped.

Thanks!