Articles

Excel: Automatic time update in cel

February 1, 2008 at 10:23:26
Specs: Windows XP, Centrino Duo 2GB Ram

Hi,

I would like to create an automatic time-tracker. In order to do so I need to have the actual time in a cell. When I use the NOW() function this only updates when I press F9. Is there any way to automate this?

Thanks!


See More: Excel: Automatic time update in cel

Report •


#1
February 1, 2008 at 11:54:58

Paste this code into a regular module and run the StartTimer code.

Public RunWhen As Double
' Set interval to 1 second
Public Const cRunIntervalSeconds = 1
' Define name of procedure to run
Public Const cRunWhat = "The_Timer"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime _
EarliestTime:=RunWhen, _
Procedure:=cRunWhat, _
Schedule:=True
End Sub

Sub The_Timer()
With [A1]
.Formula = "=now()"
.NumberFormat = "hh:mm:ss;@"
End With
StartTimer
End Sub


Report •
Related Solutions


Ask Question