Countdown Timer

  • Thread starter Thread starter Robert_NSBG
  • Start date Start date
R

Robert_NSBG

I created a spreadsheet to score my daughter's basketball games. I need to
create a"Game Clock" macro that I can set the amount of time at the start of
each period(minutes, seconds, tenths of seconds if possible) and have it
count down until the time has expired. I also need to stop and start the
timer with a button.

Can anyone help???
 
Hi,

I'm not sure about 10th seconds but here's one for H:M:S

Format A1 as HH:MM:SS and enter a duration as a time. make it nice and big.
I merged a bunch of cells and set the font to 48 point.

Alt+f11 to open VB editor and right click 'This Workbook' and insert module
and paste the code below in

Put a button on your sheet to run the TIMER sub and the clock counts down.
At any time enter a t in d1 and the clock pauses. delete the T and the clock
resumes. the sheet with the clock must remain the active sheet

Sub Timer()
CountDown = Now + TimeValue("00:00:01")
Application.OnTime CountDown, "GoClock"
End Sub
Sub GoClock()
Dim count As Range
Set count = [A1] ' Enter time in seconds
If UCase(Range("D1")) = "T" Then
count.Value = count.Value
Else
count.Value = count.Value - TimeValue("00:00:01")
End If
If count <= 0 Then
MsgBox "Game Over"
Exit Sub
End If
Call Timer
End Sub


Mike
 
Back
Top