How to create a countdown timer in a worksheet

G

Guest

How to create a countdown timer in a worksheet, like a stopwatch counting
down the seconds/minutes when you click on a START button until you click on
a STOP button
 
G

Guest

Public myStartTime As Date
Sub StartTime()
myStartTime = Date + Time

End Sub
Sub StopTime()
Dim myStopTime As Date
Dim Elapsed As Date
Debug.Print myStartTime

If myStartTime = 0 Then
MsgBox ("You have not pressed the START BUTTON first")
Else

myStopTime = Date + Time
Elapsed = myStopTime - myStartTime
MsgBox ("Elapsed time is " & Elapsed)
myStartTime = 0
End If

End Sub

Attach each macro to a different button. You may need to change the
format of Elapsed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top