Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do i stop a clock in excel
Hello,
I have a clock macro in an excel worksheet that I would like it to stop when it hits 5:30PM each day. How would I make this possible? This is what i have so far: Sub StartTiming() Call StartClock With ThisWorkbook.Sheets("Sheet1") 'Clear total elapsed time .Range("j3").ClearContents 'Format the cells with time formats .Range("j1:j3").NumberFormat = "hh:mm:ss" 'Save the start time in cell J1 .Range("j1").Value = Range("j2").Value End With End Sub Sub StartClock() With ThisWorkbook.Sheets("Sheet1") .Range("j1") = Now() End With NextTick = Now + TimeValue("00:00:01") Application.OnTime NextTick, "StartClock" End Sub Sub StopClock() 'Stop OnTime event. 'Returns error if already stopped and hense the on error handling. On Error Resume Next Application.OnTime _ EarliestTime:=NextTick, _ Procedu="StartClock", _ Schedule:=False If Err.Number > 0 Then Exit Sub On Error GoTo 0 With ThisWorkbook.Sheets("Sheet1") .Range("j3").Value _ = .Range("j2").Value - .Range("j1").Value End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't Stop the clock | Excel Discussion (Misc queries) | |||
Can't stop a clock | Excel Programming | |||
Stop the clock | Excel Programming | |||
can excel be a time clock or stop watch? | New Users to Excel | |||
Start Clock/Stop Clock | Excel Discussion (Misc queries) |