How do i stop a clock in excel

A

accsys

Hello

I have a clock macro in an excel worksheet that I would like it to stop whe
i
hits 5:30PM each day. How would I make this possible

This is what i have so far

Sub StartTiming(

Call StartCloc

With ThisWorkbook.Sheets("Sheet1"
'Clear total elapsed tim
.Range("j3").ClearContent

'Format the cells with time format
.Range("j1:j3").NumberFormat = "hh:mm:ss&quot

'Save the start time in cell J
.Range("j1").Value = Range("j2").Valu

End Wit

End Su

Sub StartClock(

With ThisWorkbook.Sheets("Sheet1"
.Range("j1") = Now(
End Wit

NextTick = Now + TimeValue("00:00:01"

Application.OnTime NextTick, "StartClock&quot
End Su

Sub StopClock(
'Stop OnTime event
'Returns error if already stopped and hense the on error handling
On Error Resume Nex

Application.OnTime
EarliestTime:=NextTick,
Procedure:="StartClock",
Schedule:=Fals

If Err.Number > 0 Then Exit Su

On Error GoTo
With ThisWorkbook.Sheets("Sheet1"
.Range("j3").Value
= .Range("j2").Value - .Range("j1").Valu
End Wit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top