Countdown Timer in Excel

Add to Favorites
Author: | Edits: don

How to create a countdown timer in Excel.

This allows you to display a timer in whatever cell you want and it will count down until it reaches zero. I also included a method to stop or pause the timer.

To create the countdown timer, a macro will be used. However, this tutorial does not require any previous knowledge of macros or VBA in Excel.

If you are familiar with VBA, you can just copy the full macro code from below and skip everything else.

Sections:

Make the Countdown Timer

Add a Stop or Pause Feature to the Timer

Add Buttons in the Spreadsheet to Control the Timer

Countdown Timer Full Macro Code

Notes

Make the Countdown Timer

To make a countdown timer we need to install a macro into Excel, don't worry though, that's easy. Before that though, we need to setup a cell in the spreadsheet to hold the timer.

  1. Go to the cell that you want to contain the timer. Right-click that cell > click Format Cells...
    a6a7731f67646ad4730839bca75d467c.png
  2. Go to the Number tab and then to the Time category and select 13:30:55 from the section on the right. Then hit OK to get back to Excel.
    7e71b50651fd8475295719536f8c92bb.png
  3. You will now have a cell formatted like this:
    6e0d06f82e3a545926fe544ab4f3ac83.png
  4. Double-click the cell and it will have an annoying 12:00:00 AM time by default, but just ignore that.
    3d0c7c60c5c29c417c50830b46246fdd.png
  5. Type whatever time you want into this cell. The first set of zeros is for hours, the second set for minutes, and the third set for seconds. Delete what appears in the cell by default and type your number like this:
    106b6cf10db49a8a3f6bc9b7f5b72797.png
    Hit enter and you get this:
    8750dfd3285a40126a53af31dc7c53b1.png
    The time in the formula bar will look weird but don't pay attention to that; it doesn't matter.
  6. Now, we add the VBA code and install the macro. To do this hit Alt + F11 to go to the VBA Editor window and then look to the menu at the top of the window and go to Insert > Module
    fc5a28f618b506281af73ecd3fcead94.jpg
  7. A window will open like this:
    ee15c0891275a242a321d2808da3df3f.jpg
    Paste the macro into this window.
    Here is the macro code:
     Sub timer()
    
         interval = Now + TimeValue("00:00:01")
    
         If Range("A1").Value = 0 Then Exit Sub
    
         Range("A1") = Range("A1") - TimeValue("00:00:01")
    
         Application.OnTime interval, "timer"
    
     End Sub
    

    It should now look something like this:
    d00beec9f145894a403ad35db6143603.jpg
  8. Change the code to work for you. Everywhere that you see cell A1 you need to change that to the cell that contains the timer in your worksheet. So, if you put the timer in cell B6, then replace every instance of A1 with B6 in the code above.
  9. Hit Alt + F11 to go back to Excel and then hit Alt + F8, select the macro timer from the window that opened, hit the Run button, and watch the time count down.
    a2b166d24a989a318b7c28c69462413a.png

When the timer gets to zero, it will stop.

Add a Stop or Pause Feature to the Timer

Now that we have a working timer, it's a good idea to be able to stop it.

To do this, we need to add just a couple things to our macro.

  1. Hit Alt + F11 and then go to the module that you added in the last section. If it isn't already open, it should be listed in the left pane of the window and it will be called Module1, double-click that.
  2. Once you see the macro, add this line of code above it:
     Public interval As Date
    

    e151ace81b03d54c73af838b6901c415.jpg
  3. Now, below all of the code, under where it says End Sub, add this macro:
     Sub stop_timer()
         Application.OnTime EarliestTime:=interval, Procedure:="timer", Schedule:=False
     End Sub
    

    d11f5dcb5ac35f4175c91d3bd88a1452.jpg
  4. Go back to Excel, Alt + F11 and then hit Alt + F8. In the window that opens click timer and hit the Run button.
    bb2a7a71746d1a0ff8c92ca25075e899.png
  5. The timer should now be running. To stop it, hit Alt + F8 again and select stop_timer and click the Run button.
    733f759861f387f595f7b9ca1d4a4434.png

That's all there is to it!

Now, always going to the Macro window, Alt + F8, can be really annoying, so let's make these macros run from some buttons in the worksheet.

Add Buttons in the Spreadsheet to Control the Timer

This is a simple feature once you've got working macros.

Simply go to the Insert menu and select Shapes and then select a rounded rectangle.

9c35bbba253415c7e1f0d2e7e9f1d730.jpg

Adjust the size of the buttons and add some text to them.

a7b091113e953d4f09985f976de44a17.png

Right-click the first button and click Assign Macro...

40570218bb02612d5eb770c6adbe3319.png

In the window that opens, click timer and hit OK.

9605fd226db37c5fa291bddfb439ac73.png

Repeat that for the next button, obviously selecting stop_timer this time.

That's it!

52359ec6ced46e5a9cf883f8f493bae6.png

If you want to learn more about adding buttons to Excel and making them run macros, check out this tutorial:

Attach a Macro to a Button in Excel

Countdown Timer Full Macro Code

Here is the complete macro code needed for this timer:

Public interval As Date
Sub timer()
 
    interval = Now + TimeValue("00:00:01")
    
    If Range("A1").Value = 0 Then Exit Sub
    
    Range("A1") = Range("A1") - TimeValue("00:00:01")
    
    Application.OnTime interval, "timer"
     
End Sub
Sub stop_timer()
 
    Application.OnTime EarliestTime:=interval, Procedure:="timer", Schedule:=False
 
End Sub

This code goes into a regular module.

Notes

When you first start the timer it may seem to count fast for the first couple seconds but it should quickly correct itself.

To make this macro run when the Excel workbook is opened, read these tutorials:

How to Run a Macro Automatically when Excel is Opened

How to Run a Macro from Another Macro

Make sure to download the spreadsheet attached to this tutorial so you can see everything in Excel and more easily copy/paste what you need.


Downloadable Files: Excel File

Question? Ask it in our Excel Forum


Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Similar Content on TeachExcel
Run a Macro at Set Intervals in Excel
Tutorial: Run a macro every 30 seconds, 1 minute, 10 minutes, 1 hour, etc.; this method allows you t...
Years, Months, Days Between two dates in Excel
Tutorial: I have found a rather convoluted method to Calculate the Number of Years, Months and Days ...
Turn Off the Formatting Window Popup in Excel
Tutorial: How to stop the annoying formatting window, the "Mini Toolbar" from appearing when you se...
Format a Date to Show Only the Day of Week in Excel
Tutorial: How to format a Date so that only the day of the week is visible from that date. Result: ...
Manually Calculate Formulas and Functions in Excel
Tutorial: How to force Excel to recalculate all formulas and functions without editing or entering ...
Idiot-Proof Forms in Excel - Part 1 - Formatting
Tutorial: Forms Course This tutorial shows you how to create a form within a regular worksheet in E...
Tutorial Details
Downloadable Files: Excel File
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course