Stamp Date

Malcolm torishi

Board Regular
Joined
Apr 26, 2013
Messages
219
I have the following vba time stamp code in a module that does not quite do what I want it to do. I would like the clock to start automatically rather than having to go into the marco and run “Recalc”. Also I would like to close the spread sheet in a normal way rather than when i close the spread sheet the spread sheet closes for a split second and then reopens because the clock is still in “Recalc”
Can any one suggest what extra code I would need to add to the following
thanks

Dim SchedRecalc As Date
Sub Recalc()
With Sheet1.Range("G1")
.Value = Format(Time, "hh:mm:ss AM/PM")
End With
Call Settime
End Sub
Sub Settime()
SchedRecalc = Now + TimeValue("00:00:01")
Application.OnTime SchedRecalc, "Recalc"
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Call Recalc from Workbook_Open and call StopTimer from Workbook_Close, both in the ThisWorkbook module.

Code:
Sub StopTimer()
    On Error Resume Next
    Application.OnTime EarliestTime:=SchedRecalc,Procedure:="Recalc", Schedule:=False
End Sub
 
Upvote 0
Hi thank you for coming back, I have tried this out today but couldn’t get it to work. I have obviously inserted the code into the wrong place . Any chance you could explain more please.
thank you
 
Upvote 0
Hello again
For some strange reason I can only get the beginning of this code to work. Eg the open Recalc. The stop timer section of the code locks up and I get a yellow highlighted line over the private sub line line in the code. It works great when the spread sheet opens, the clock is ticking but it just will not allow me to close and save the spreadsheet without going into this yellow highlighted line over the private sub line. If you can help thank you , otherwise I will have another go tomorrow, thank you agian
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
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