Setting timer to run macro at regular intervals

S

sun

Dear Excel Gurus,

Can I set a timer to run a macro at regular time intervals? Is there a
convenient API to use?

Thank you very much in advance.
 
M

Mike H

Hi,

You can us Ontime

This goes in the workbook open event module to kick things off

Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:01:00"), "MyMacro"
End Sub

and this goes in a general module

Public dTime As Date
Sub MyMacro()
dTime = Now + TimeValue("00:01:00")
Application.OnTime dTime, "MyMacro"

'Your code

End Sub

As written this runs MyMacro every 1 minute, change this to what you want

Mike
 
J

JLGWhiz

In Windows 2003, Go to Start>All Programs>Accessories>System Tools>Scheduled
Tasks. Then click on the folder icon to bring up the scheduled tasks wizard.
This will allow you to start Excel programs without having to open Excel or
a Workbook. Just follow the Wizard prompts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top