Alex
I believe Celia has answered this somewhere ??
BUT have a look @ this routine (I think it is
one of Chips ??) BUT look @ the online help
for Ontime
Option Explicit
Public RunWhen As Double
Public Const cRunIntervalSeconds = 10 ' secons
Public Const cRunWhat = "The_Sub"
'Use Now + TimeValue(time) to schedule something to be run when a specific amount of time
'(counting from now) has elapsed. Use TimeValue(time) to schedule something to be run at
'a specific time.eg TimeValue("21:30") runs it @ 9:30pm
Sub StartTimer()
MsgBox "Timer will start after every; " & cRunIntervalSeconds
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub
Sub StartTimer_ST()
'MsgBox "Timer will start after; " & cRunIntervalSeconds
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub
Sub The_Sub()
'--------------------
' Put your code here'
'--------------------
StartTimer
End Sub
HTH
Ivan