I'm trying to make a countdown timer in Excel similar to what is explained in this video:
https://www.youtube.com/watch?v=sbJeGG_Xv8M
I was able to re-create what is in the video, however I'm hoping someone here can help me with two modifications:
Any assistance on this would be greatly appreciated!! I've copied the code from the video below for reference:
https://www.youtube.com/watch?v=sbJeGG_Xv8M
I was able to re-create what is in the video, however I'm hoping someone here can help me with two modifications:
- With this code as it is, the clock stops if you do anything else in the Excel file while it's running. Anybody know a way around this so that the clock in the text box will still run while other cells are being manipulated? The author of the above video alludes to this problem in the comments and mentions a fix that he will follow up on, but hasn't updated it yet.
- Anybody know of a way to have this clock reset when a value is entered in multiple ranges? For example, in the following screenshot, I would want the clock to reset to a value (let's say 5 minutes) and begin counting down again as soon as any value is entered in any of the yellow cells (and reset over and over again as those cells become populated). Hope that makes sense.
Any assistance on this would be greatly appreciated!! I've copied the code from the video below for reference:
Code:
Sub starttimer()
Application.OnTime Now + TimeValue("00:00:01"), "nexttick"
End Sub
Sub nexttick()
If Sheet1.Range("B1") = 0 Then Exit Sub
Sheet1.Range("B1").Value = Sheet1.Range("B1").Value - TimeValue("00:00:01")
If Sheet1.Range("B1").Value <= TimeValue("00:00:30") Then
Sheet1.Shapes("TextBox 1").Fill.ForeColor.RGB = RGB(255, 0, 0)
Else
Sheet1.Shapes("TextBox 1").Fill.ForeColor.RGB = RGB(129, 229, 243)
End If
starttimer
End Sub
Sub stoptimer()
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "nexttick", , False
End Sub