Running Clock w/ Freeze

soundswarm

New Member
Joined
Oct 26, 2005
Messages
5
I would like to have a running clock in cell A1 based on my system's time and have a button to press so I can freeze it. Any ideas?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi,

don't use a cell to do this, but use a textbox
using a cell has major drawback*: it will disable, cut copy paste

in thisworkbookmodule
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopIt
'ThisWorkbook.Save
End Sub

Private Sub Workbook_Open()
RunIt
End Sub
in normal module
Code:
Option Explicit

Dim RunOnTime As Double
Dim LastRun As Double

Sub RunIt()
Dim sec As Integer

sec = 1 'procedure will run each ... second(s)
    
LastRun = Timer

Sheets(1).TextBox1 = Time
    
RunOnTime = Now + sec / 60 / 60 / 24
Application.OnTime RunOnTime, "RunIt", , True


End Sub

Sub StopIt()
On Error Resume Next
Application.OnTime RunOnTime, "RunIt", , False
RunOnTime = 0
End Sub

*if you absolutely want to use a cell, whithout the drawback, there is a trick: use running-clock on other (hidden) sheet and refer to there with a formula

kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,222,688
Messages
6,167,643
Members
452,127
Latest member
jayneecm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top