Hi All,
I have vba userform you can find ss below. When a user clicks on pause it changes to resume but its not changing to pause when clicking resume. And I want calculate time between those clicks
Here is a code that I used. This code is in command button
Private Sub CommandButton3_Click()
Static startTime As Date
Static pauseTime As Date
Static isPaused As Boolean
If Not isPaused Then
' Start the timer
startTime = Now()
CommandButton3.Caption = "Resume"
isPaused = False
Else
' Pause the timer
pauseTime = Now()
CommandButton3.Caption = "Pause"
isPaused = True
End If
End Sub
This code is in form
Private Sub UserForm1_Activate()
' Initialize the timer
startTime = Now()
pauseTime = startTime
End Sub
Dim elapsedTime As Date
If isPaused Then
elapsedTime = pauseTime - startTime
Else
elapsedTime = Now() - startTime
End If
ThisWorkbook.Sheets("Form").Range("G2").Value = Format(elapsedTime, "hh:mm:ss")
Please help me in solving this. Am trying to get it from 4 days
Thanks in Advance
I have vba userform you can find ss below. When a user clicks on pause it changes to resume but its not changing to pause when clicking resume. And I want calculate time between those clicks
Here is a code that I used. This code is in command button
Private Sub CommandButton3_Click()
Static startTime As Date
Static pauseTime As Date
Static isPaused As Boolean
If Not isPaused Then
' Start the timer
startTime = Now()
CommandButton3.Caption = "Resume"
isPaused = False
Else
' Pause the timer
pauseTime = Now()
CommandButton3.Caption = "Pause"
isPaused = True
End If
End Sub
This code is in form
Private Sub UserForm1_Activate()
' Initialize the timer
startTime = Now()
pauseTime = startTime
End Sub
Dim elapsedTime As Date
If isPaused Then
elapsedTime = pauseTime - startTime
Else
elapsedTime = Now() - startTime
End If
ThisWorkbook.Sheets("Form").Range("G2").Value = Format(elapsedTime, "hh:mm:ss")
Please help me in solving this. Am trying to get it from 4 days
Thanks in Advance