Stopwatch/Clock
To start you off, try something like:
Option Explicit
Dim ClockRunning As Boolean
Sub StartClock()
ClockRunning = True
ControlClock
End Sub
Sub StopClock()
ClockRunning = False
End Sub
Sub ControlClock()
If ClockRunning = True Then
Range("A1") = Format(Now, "hh:mm:ss")
Application.OnTime Now + TimeValue("00:00:01"), "ControlClock"
End If
End Sub
To start the clock, just run the StartClock macro, and the StopClock
macro to stop the code.
You can expand the functionality from here to do all sorts of funky things
Hope this helps.
Scott
Easty wrote:
I want to display the time in a worksheet but want it to update automatically like a clock.
It is to be used like a clock at a football game - any ideas.
I have done it by using a macro to paste the time the game starts in a cell and then use Now()-start time to give elapsed time.
I then have a macro to f9
I'm sure it can be done automaticly every second but don't know how.
Any ideas?
|