ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Is there a formula for a timer (https://www.excelbanter.com/excel-discussion-misc-queries/244840-there-formula-timer.html)

1965cs

Is there a formula for a timer
 
Is there a formula for a xcell that will count current time, IE display as a
clock or timer?

Mike H

Is there a formula for a timer
 
Hi,

If you mean an updating digital clock then the answers no, you have to make
your own.

Alt+F11 to open VB editor. Right click 'This Workbook' and insert module and
paste the code below in. Run the 'StartClock module and you get your clock in
Sheet 1 - A1. Stop it manually when exiting Excel or better still put the
StopClock sub in the before close event.

Dim Go As Boolean
Sub StartClock()
Go = True
MyClock
End Sub

Sub MyClock()
If Go Then
Worksheets("Sheet1").Cells(1, 1).Value = Format(Now, "hh:mm:ss")
Application.OnTime (Now + TimeSerial(0, 0, 1)), "MyClock"
End If
End Sub

Sub StopClock()
Go = False
End Sub

Mike

"1965cs" wrote:

Is there a formula for a xcell that will count current time, IE display as a
clock or timer?



All times are GMT +1. The time now is 04:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com