How to create a countdown timer in a worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top