timestamp now() vs live clock

palaeontology

Active Member
Joined
May 12, 2017
Messages
444
Office Version
  1. 2016
Platform
  1. Windows
In sheet 1 cell B2 I'm returning a live clock using the following code placed in Module 1 ...

VBA Code:
Dim SchedRecalc As Date

Sub Recalc()
  Application.Volatile
  With Sheet1.Range("B2")
    .Value = Format(Time, "hh:mm:ss AM/PM")
  End With
  SchedRecalc = Now + TimeValue("00:00:01")
  Application.OnTime SchedRecalc, "Recalc"
End Sub

Sub Disable()
  On Error Resume Next
  Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
End Sub

In sheet 1 cell B1 I'm trying to return just a timestamp (also in hh:mm:ss AM/PM format) of when a Form Control Command Button is pressed. The Command Button is assigned the following macro stored in Module 2 ...

Code:
Sub startTimeinB1()

    Range("B1").Select
    ActiveCell.FormulaR1C1 = "=NOW()"
    
End Sub

However, the time in B1 (which should not be changing as time ticks by) is changing every second, just like the live clock in cell B2.

Is there a way I can change my code(s) to prevent the time in B1 from updating ?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this instead:

VBA Code:
Sub startTimeinB1()

    Sheet1.Range("B1").Value = Now
 
End Sub

If you want to use the same formatting, replace the line with:

VBA Code:
Sheet1.Range("B1").Value = Format(Now, "hh:mm:ss AM/PM")
 
Upvote 0
Solution

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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