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

CountDown Timer in Excel

0

HI,

I have watched the tutorial on how to have a countdown timer in Excel. I have managed to to get it to work. I have set the start time at 7:30 and if I push Start it counts down. If I click Stop it stops and RESET it resets. Perfect. However, if i click STOP before STARTING, by accident I get an error. Can this be overcome?

And now I've been playing with it I cant run the timer as it tells me the file is missing.

This is above my payscale!!

AAll help appreciated.

I'm in New Zealand

thanks Kevin

Answer
Discuss

Answers

0
Selected Answer

Hi Kevin and welcome to the Forum

Assuming you're referring to Don's tutorial Countdown Timer in Excel, just add this line in bold to the Stop macro:

Sub stop_timer()
' TeachExcel.com

    ' Stop the timer macro from running
    On Error Resume Next
    Application.OnTime EarliestTime:=interval, Procedure:="timer", Schedule:=False

End Sub
You latterly attached two files and my guess is that you were trying to add the Timer code to your score book file. Here's a revised file where the macro module (with the addition above) is added to the score sheet. I've assumed you'll always start/stop/reset the timer from the restored buttons on that sheet (so the tutorial code is hardly changed).

Hope this is what you wanted.

Discuss

Discussion

Kevin. Not sure about the "missing file" message. Suggest you download the Excel file form the Tutorial again.
John_Ru (rep: 6152) Jun 28, '21 at 8:27 am
Hi John,
thanks for that. If I could share a screen shot of my workbook that might help. How do I attach a file to this message thread?
MorrinsvillePoloClub (rep: 2) Jun 28, '21 at 9:39 am
Kevin
You can't attach anything but an Excel file. Go to your original question and use the Attach Files button (below the question text) to do that. 
John_Ru (rep: 6152) Jun 28, '21 at 10:20 am
Did I guess your intention correctly?
John_Ru (rep: 6152) Jun 29, '21 at 7:55 am
Sorry, not sure I know what you mean?
MorrinsvillePoloClub (rep: 2) Jun 29, '21 at 5:57 pm
Kevin. I meant to ask if the modified file gave you what you wanted. Please note that if my Answer resolved your question, you should mark it as Selected (which also guides other users looking for working solutions). 
John_Ru (rep: 6152) Jun 30, '21 at 1:06 am
I'll have to keep playing with the workbook as I have messed things up somewhat. May even have to start again.
Will let you know when I redo it if all is successful

thanks Kevin
MorrinsvillePoloClub (rep: 2) Jun 30, '21 at 5:13 am
Kevin
You can just download my file again (if that helps). Thanks for selecting my answer and good luck.
John_Ru (rep: 6152) Jun 30, '21 at 6:06 am
Using this Code it works great!!! However... Is there anyway to have the clock always run even when I am in another cell adding text or data? The clock stops til I click "Enter" as of right now

 ' Check if the timer is finished and exit the macro if it is     If Range("I5").Value = 0 Then Exit Sub   On Error Resume Next          ' Remove 1 second from the timer     Sheets("ScoreBoard").Range("I5").Value = Range("I5").Value - TimeValue("00:00:01")                 ' Set when the macro should run again - should be the same time value as the previous line.     interval = Now + TimeValue("00:00:01")          ' Make this macro run again in 1 second     Application.OnTime interval, "timer"

jebsound85 Nov 20, '22 at 10:01 pm
Jeb

Sorry but I can't think of an easy way to do that. Application.Ontime is primarily intended to schedule tasks (where the chances of you entering text in say 20 minutes time are comparatively low) but this code uses it as a 1 second countdown timer so it's likely that you'd see the pause.

I could probably create a way to compensate for the time spent typing (so it looks like the timer continued running in the background) but you should ask a new, separate question and hopefully Don (who creates the tutorials) will answer you. Be sure to reference the Countdown Timer in Excel tutorial.
John_Ru (rep: 6152) Nov 21, '22 at 5:56 am
Hi all,
I am using the countdown timer vba code of Don's tutorial.
And It seems does not run ok sometimes.
If I dont let the timer Go to zero closing Excel before that, then the timer starts properly again when the file is open. But when I let timer runs untill zero and Excel closes automatically with another code...and when I open It again then most of the times the timer does not work.
Please can somente help.
BR Frex

FREX_420 (rep: 6) Jan 25, '23 at 5:14 pm
Hi BR Frex and welcome to the Forum.

This question has been answered- please create a new question (and hopefully someone will reply).
John_Ru (rep: 6152) Jan 25, '23 at 5:58 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login