This is the code that I wrote for the start/stop/reset program that works with the 3 buttons on my sheet.(they are just shapes that were assigned a macro).
The timer is working but cannot pause
Option Explicit
Sub StartTimer()
'Setting the procedures to assign
Dim Start As Single, RunTime As Single
Dim ElapsedTime As String
'Set the control cell to 0 and make it green
Range("C1").Value = 0
Range("A1").Interior.Color = 5296274 'Green
Start = Timer ' Set start time.
Debug.Print Start
Do While Range("C1").Value = 0
DoEvents ' Yield to other processes.
RunTime = Timer ' current elapsed time
ElapsedTime = Format((RunTime - Start) / 86400, "hh:mm:ss")
'Display currently elapsed time in A1
Range("A1").Value = ElapsedTime
Application.StatusBar = ElapsedTime
Loop
Range("A1").Value = ElapsedTime
Range("A1").Interior.Color = 192 'Dark red
Application.StatusBar = False
End Sub
Sub PauseTimer()
'Pause the timer to add the time to each instance
StartTimer.Pause
End Sub
Sub StopTimer()
'Set the control cell to 1
Range("C1").Value = 1
End Sub
'Procedure to be execuetd when the button reset is done
Sub ResetTimer()
Dim show As Variant
'When the timer is reset display the time so that it could be added together as a sum for our time budgets
show = Range("A1").Value
If Range("C1").Value > 0 Then
'Set the control cell to 1
Range("A1").Value = Format(0, "hh:mm:ss")
Range("D4").Value = show
End If
End Sub
Sub StartCountdown()
Dim ZeroHour As Date
Dim TimeDifference As Single
'Set the control cell to 0 and make it green
Range("C6").Value = 0
Range("A6").Interior.Color = 5296274 'Green
ZeroHour = Range("A5").Value ' Set start time.
TimeDifference = ZeroHour - Now
If TimeDifference <= 0 Then
Range("A6").Value = "Error : date/time in the past"
StopCountdown
Exit Sub
End If
Do While Range("C6").Value = 0 And TimeDifference > 0
DoEvents ' Yield to other processes.
TimeDifference = ZeroHour - Now
Range("A6").Value = Int(TimeDifference) & "d " & Format((TimeDifference), "hh:mm:ss")
Application.StatusBar = Int(TimeDifference) & "d " & Format((TimeDifference), "hh:mm:ss")
Loop
Range("A6").Interior.Color = 192 'Dark red
Application.StatusBar = False
End Sub
Sub StopCountdown()
'Set the control cell to 1
Range("C6").Value = 1
End Sub
Sub ResetCountdown()
If Range("C6").Value > 0 Then
'Set the control cell to 1
Range("A6").Value = "0 d " & Format(0, "hh:mm:ss")
End If
End Sub