Stop Watch / Chronometer for excel

brites

Board Regular
Joined
Aug 19, 2004
Messages
224
Hi folks, does anyone know how to build a stop watch or chronometer in excel? Anyone ever saw one?

Thanx in advance!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Erik,
ive just sent you an email.
Thanx for your help!

Thats just way above my vba limitations!
:)
 
Upvote 0
email sent

for future reference: how it works
some controls needed
buttons
ExitBtn
ResetBtn
StartBtn
StopBtn
LapBtn
Labels
ElapsedTimeLbl
Laplbl
Code:
Option Explicit

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

Private Sub ExitBtn_Click()
StopTimer = True
Unload Me
End Sub

Private Sub ResetBtn_Click()
StopTimer = True
Etime = 0
Etime0 = 0
LastEtime = 0
ElapsedTimeLbl.Caption = "00:00:00.00"
End Sub

Private Sub StartBtn_Click()
StopTimer = False
Etime0 = timer() - LastEtime
Me.Repaint

    Do Until StopTimer
    Etime = Int((timer() - Etime0) * 100) / 100
        If Etime > LastEtime Then
        LastEtime = Etime
        ElapsedTimeLbl.Caption = Format(Etime / 86400, "hh:mm:ss.") & Format(Etime * 100 Mod 100, "00")
        DoEvents
        End If
    Loop

End Sub

Private Sub StopBtn_Click()
StopTimer = True
Laplbl = ""
Beep
End Sub

Private Sub LapBtn_click()
Laplbl.Caption = ElapsedTimeLbl
lapnr = lapnr + 1
Range("A" & lapnr) = "lap " & lapnr
Range("B" & lapnr) = ElapsedTimeLbl
End Sub

Private Sub UserForm_Activate()
Range("A:B") = ""
ElapsedTimeLbl = "00:00:00.00"
End Sub
 
Upvote 0
Erik,
great solution.
I was wondering, is there a way that i can use both buttons combined?
I mean, i want to be warned in 10 seconds... but i wanna be able to see to chronometer up to that point.
 
Upvote 0
I GOT IT!

Thanx!

Sub StartBtn_Click()
StopTimer = False
Etime0 = timer() - LastEtime

Do Until StopTimer
Etime = Int((timer() - Etime0) * 100) / 100
If Etime > LastEtime Then
LastEtime = Etime
ActiveSheet.Cells(1, 1).Value = Format(Etime / 86400, "hh:mm:ss.") & Format(Etime * 100 Mod 100, "00")
DoEvents
End If
Loop

End Sub
 
Upvote 0
Greetings,

I'm fairly new to VBA's and ok with Excel. I'm trying to use the code for the stopwatch found in this thread and I can't get it to work. I've cut and pasted the code in and made the buttons but I don't know what to do with the labels. I tried to go to Insert>name>label in a cell but that didn't do anything. Any help would be much appreciated
 
Upvote 0
I try to run the Macro and it gives me a compile error; "in valid use of the Me keyword. I've done extensive searching but haven't found anything that has helped me yet.
 
Upvote 0
Well...........After tinkering forever and asking a lot of friends, I got this macro to work. But if I enter data into other cells, the stopwatch stops running. Is there anything I can write in the macro to have the stopwatch keep running and input other data into the worksheet at the same time.

Again, I'm not very good at this and I'm struggling so any help would be much appreciated.

Thanks in advance!
 
Upvote 0

Forum statistics

Threads
1,225,217
Messages
6,183,637
Members
453,177
Latest member
GregL65

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