Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pausing a Macro vs Stopping and Starting 3

Status
Not open for further replies.

Bass71

MIS
Jun 21, 2001
79
Hi;

I have to run a Do-Loop section of code every five minutes, for an 8 hour interval. I have the following code:

Application.Wait Now() + TimeSerial(0, 5, 0)

...although it works, the macro running continuously and I am afraid I increase the chance of crashing.

Is there a better way of executing this in which the macro rests for 5 minutes and then starts again?

thanks for your help...
 
Hi Bass71,

Application.OnTime should do what you want. try something like ..

Code:
Application.OnTime EarliestTime:=Now() + TimeSerial(0, 5, 0), Procedure:="
Code:
ProcName
Code:
"

But do give yourself a way to stop it going forever.

Enjoy,
Tony
 
Tony,
Thanks again! One more neat trick you've taught me without my even asking. Another star for you. Btw: congratulations on the Tipmaster award.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top