Making a timer in excel

mclau152

New Member
Joined
Jul 7, 2014
Messages
28
I'm looking to make a simple timer that adds 1 for every second that passes, doesn't have to be in hh:mm:ss format, just a simple number cell that starts at a value and adds 1 every second.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Simple is relative. Take a look at this macro. You will need to place it into the Workbook object where you want the code to run. Additionally, there are some parts that you will need to edit to fit your own set up. My suggestion is to first place this into a blank workbook and run. If it works ok, then edit to your working workbook.

For the line <b>Application.OnTime SchdTime + OneSec, "Sheet12.NextTick"</b>, you will need to change Sheet12 to your own worksheet name. Not the name that you have changed it to, but the "original". For example, for my test workbook, I have it set up with Sheet12(My Test) and Sheet12 is where the code is located. Let me know if you have more questions.

Code:
Dim StopTimer           As Boolean
Dim SchdTime            As Date
Dim Etime               As Date
Const OneSec            As Date = 1 / 86400#

Private Sub ResetBtn_Click()
    StopTimer = True
    Etime = 0
    [B3].Value = "00:00:00"
End Sub

Private Sub StartBtn_Click()
   StopTimer = False
   SchdTime = Now()
   [B3].Value = Format(Etime, "hh:mm:ss")
   Application.OnTime SchdTime + OneSec, "Sheet12.NextTick" 'Change Sheet12 to your own sheet name
End Sub

Private Sub StopBtn_Click()
    StopTimer = True
    Beep
End Sub

Sub NextTick()
   If StopTimer Then
   Else
      [B3].Value = Format(Etime, "hh:mm:ss")
      SchdTime = SchdTime + OneSec
      Application.OnTime SchdTime, "Sheet12.NextTick" 'Change Sheet12 to your own sheet name
      Etime = Etime + OneSec
   End If
End Sub
 
Upvote 0
how about a simpler timer which just adds seconds as they pass, so a cell with just seconds going up to 60, creating a 1 in the cell next to it being minutes, and so on and so forth
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,613
Members
449,238
Latest member
wcbyers

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