Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public RunWhen As Double
- Public Const cRunIntervalSeconds = 10 ' two minutes
- Public Const cRunWhat = "TheSub" ' the name of the procedure to run
- Sub StartTimer()
- RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
- Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
- Schedule:=True
- End Sub
- Sub TheSub()
- ''''''''''''''''''''''''
- ' Your code here
- MsgBox "hi"
- ''''''''''''''''''''''''
- StartTimer ' Reschedule the procedure
- End Sub
- Sub StopTimer()
- On Error Resume Next
- Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
- Schedule:=False
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment