Timer in Excel

ryeire

New Member
Joined
Jan 31, 2022
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am looking to create two buttons which control a timer in excel. I would like one button to start and reset the timer when pressed, and I would like the other button to stop the timer. Any help would be appreciated
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Seems like you want a timer to just keep on advancing until you click stop button, but are you also watching a display advance, or just incrementing a timer you can't see? This would do the latter (assumes you have a start and stop button on a form). Note: save all work before running in case you get stuck in a loop and have to force a shutdown. I tested this in Access and it works without any issue, but basically does nothing except advance the built in timer.
This has to go in the declarations section (just under Option Explicit)
VBA Code:
Public TimerValue As Variant
These are the button click events
VBA Code:
Private Sub cmdStart_Click()

TimerValue = Timer
Do While TimerValue <> 0
   TimerValue = TimerValue + 1
   DoEvents
Loop

End Sub

VBA Code:
Private Sub cmdStop_Click()
TimerValue = 0
End Sub
 
Upvote 0
Solution
This is perfect, I have no need to show the timer. Thank you very much
 
Upvote 0
Glad to help. Can you mark this thread as solved if all done?
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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