ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting timer to run macro at regular intervals (https://www.excelbanter.com/excel-programming/422266-re-setting-timer-run-macro-regular-intervals.html)

Mike H

Setting timer to run macro at regular intervals
 
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

"sun" wrote:

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.





All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com