The NOW function
Thanks Bob, that looks promising, however I'm not sure exactly how to run
this code. I assume that I need a sheet labelelled "Sheet1" and that the
clock will appear in cell A1? Perhaps I've entered the code wrong.My VBA
module looks like this:
====
Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "The_Sub"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _
schedule:=True
End Sub
Sub The_Sub()
Dim nTime As Double
Sub myClock()
nTime = Now + TimeSerial(0, 0, 1) ' 1 secs
Worksheets("Sheet1").Range("A1").Value = Time
Application.OnTime nTime, "myClock"
End Sub
Sub StopClock()
Application.OnTime nTime, "myClock", , False
End Sub
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedu=cRunWhat, schedule:=False
End Sub
====
Should I have put your block somewhere else?
Thanks
Atreides
|