Thread: Stop timer.
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Stop timer.

Hi Karthi,

Note that NextTick need to be declared in the declarations area at the top
of the module so that it is available to all subs in the module.

Dim NextTick

Sub StopClock()
'Stop OnTime event.
'Returns error if clock already stopped and hense the On Error handling.
On Error Resume Next
Application.OnTime _
EarliestTime:=NextTick, _
Procedu="Clock", _
Schedule:=False
If Err.Number 0 Then Exit Sub
On Error GoTo 0
End Sub

--
Regards,

OssieMac


"Karthik" wrote:

Hi All,

I copied a script from discussions given below to prepare a rudementary clock.

Sub Clock()
ThisWorkbook.Sheets("Sheet1").Range("g7").Value = CDbl(Time)
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "Clock"
End Sub

I would like to have a seperate macro to stop this clock from calculating.

Thanks for your help in advance.....!

--
Karthi