Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clock within Excel 1

Status
Not open for further replies.

Molby

Technical User
May 15, 2003
520
GB
Is there anyway using VBA or not to get a clock in Excel. I know how to call up the current time, but as far as I can see that only takes a snapshot of the time the function is carried out. Is there anyway to get Excel to keep on refreshing itself?

Thanks in advance,

Ian
 
Place tios in a standard module:
[tt]Sub xlTimer()
With Application
.StatusBar = Format(Time, "hh:mm:ss")
.OnTime Time + TimeValue("00:00:01"), "xlTimer"
End With
End Sub[/tt]

You can start it in open procedure (Thisworkbook module):
[tt]Private Sub Workbook_Open()
Call xlTimer
End Sub[/tt]

Set Application.statusbar=false after breaking code to restore status bar.

combo

 
Thanks Combo, one more thing, is there a way to assign this code to a command button. When I paste the code in and compile it, I get an error. It highlights the word time and says "Expected variable or procedure, not module". Any ideas?
 
I put the code (xlTimer procedure) to a standard module. There are no variables or modules named "xlTimer". If you use activex button, put
[tt]Call xlTimer[/tt]
to its code (Private Sub ButtonName_Click() )

combo
 
Of course, silly me, didn't think of that.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top