Countdown Timer in a single cell in Excel

davin2929

Board Regular
Joined
Oct 13, 2002
Messages
129
Is there a timer function in which i can have a countdown in seconds in a single cell in MS excel?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
This (Count_Down_Timer) counts down 60 secs to 0 in A1. It also puts a message in B1. Adapt to suit.

Option Explicit
Option Base 1

Dim AlarmTime As Date, AlarmTime2 As Date
Sub Count_Down_Timer()
ActiveSheet.Range("A1").Value = 60
ActiveSheet.Range("B1").Value = "Counting"
Call TrapTime
Call TrapTime2
End Sub
Private Sub ShowTimeLeft()
ActiveSheet.Range("A1").Value = Second(AlarmTime - Now)
Call TrapTime2
End Sub
Private Sub TrapTime()
AlarmTime = CDate(Date) + TimeValue(Now()) + TimeValue("00:01:00")
Application.OnTime earliesttime:=AlarmTime, procedure:="StopTimer"
End Sub
Private Sub TrapTime2()
AlarmTime2 = CDate(Date) + TimeValue(Now()) + TimeValue("00:00:01")
Application.OnTime earliesttime:=AlarmTime2, procedure:="ShowTimeLeft"
End Sub
Private Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=AlarmTime2, procedure:="showtimeleft", schedule:=False
On Error GoTo 0
ActiveSheet.Range("B1").Value = "Done"
End Sub
 
Upvote 0
I can't get this code to work - what am I missing - can someone walk me through how to get this code 'into' a spreadsheet and assigned to a button - I think I can get it modified from there. Thanks.
 
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