Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Stop the clock NDBC Excel Discussion (Misc queries) 2 July 4th 09 01:36 AM
Can't stop a clock NDBC Excel Programming 1 July 4th 09 01:03 AM
Stop the clock J.W. Aldridge Excel Programming 1 February 10th 09 10:16 PM
can excel be a time clock or stop watch? Anthony Reynard Chinnis New Users to Excel 1 February 15th 06 06:51 AM
Start Clock/Stop Clock abfabrob Excel Discussion (Misc queries) 9 June 28th 05 04:26 PM


All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"