Help with a stopwatch on a userform?

BLyons14

New Member
Joined
Dec 30, 2014
Messages
6
Hi -

So I'm trying to get a stopwatch on a userform that has a bunch of other fields as well.

This is the code that I'm using:

Dim StopTimer As Boolean
Dim Etime As Single
Dim Etime0 As Single
Dim LastEtime As Single


End Sub


Private Sub TimeReset_Click()
StopTimer = True
Etime = 0
Etime0 = 0
LastEtime = 0
TimeBox.Value = "00:00:00.00"
End Sub


Private Sub TimeStart_Click()
StopTimer = False
Etime0 = Timer() - LastEtime
Do Until StopTimer
Etime = Int((Timer() - Etime0) * 100) / 100
If Etime > LastEtime Then
LastEtime = Etime
TimeBox.Value = Format(Etime / 86400, "hh:mm:ss.") & Format(Etime * 100 Mod 100, "00")
DoEvents
End If
Loop
End Sub


Private Sub TimeStop_Click()
StopTimer = True
Beep
End Sub



Right now, the stop watch begins counting, but the stop and reset buttons do not work. When I hit submit on the form, it copies the time to another worksheet (as it should) but there is no way to stop the clock unless I hit submit.

I have the first four lines in the Initialize section of the Userform.

Thanks for your help!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
BLyons14, if you are facing issue submitting please share you submit code and let us see what it is doing.
also please share the result you expect when you click on submit. :)

regards
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top