Updating now() automatically

BENSONJR

New Member
Joined
Sep 13, 2009
Messages
10
UPDATING NOW() AUTOMATICALLY


I have the =NOW() formula in several worksheets. How can I have them automatically updated, let’s say every 5 seconds? Thank you very much for your help . . .

Please also see my question about the code I cannot run. Thanks again
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hello Benson

I can do it by assigning a start clock and stop clock button like this

Code:
Sub TimerMe()
Range("B1").Value = 1
Do While Range("B1").Value = 1
Application.OnTime Now + _
TimeValue("00:00:01"), "Refresh"
Exit Do
Loop
End Sub
Sub Refresh()
Calculate
If Range("B1").Value = 1 Then
TimerMe
Else
Exit Sub
End If
End Sub

Sub stopClock()
Range("B1").Value = 0
End Sub

But that seems really resource heavy to have running all of the time. If I think of anything else I will post later

Danny
 
Upvote 0
Hi Benson, try this..

In your workbook put this code...

Code:
Dim bolOpening As Boolean
Dim t As Date
Private Sub Workbook_Open()
Flag = True
    RunWhen = Now + TimeSerial(0, 0, 1)
    Application.OnTime RunWhen, "UpdateClock"
t = Now
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Flag = False
    Call StopClock
End Sub

In a standard module put this...

Code:
Option Explicit
Public Flag As Boolean
Public RunWhen As Double
Sub UpdateClock()
    If Flag = True Then
'       *** Change Sheet name and Range reference to suit ***
        Worksheets("Search").Range("O2").Calculate
        RunWhen = RunWhen + TimeSerial(0, 0, 1)
        Application.OnTime RunWhen, "UpdateClock"
    End If
End Sub
Sub StopClock()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:="UpdateClock", Schedule:=False
End Sub

This will update your clock every second, I hope it helps.

Ak
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,179
Members
448,948
Latest member
spamiki

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