Changing colors of the backround

uniden32

New Member
Joined
Sep 19, 2010
Messages
22
I currently have a timer routine that counts down from 30 minutes. I display the current time remaining in the countdown, as it counts down.

What I would like to do is have it change the color of the backround for that cell when the timer hits 30 seconds left, then 15, then 5, then every second after that until it hits zero.

Here is the code I'm using (courtesy of VoG and a few alterations)

Code:
Dim NextTick As Date

Sub StartTimer()
With ThisWorkbook.Sheets("Data").Range("D2")
    .NumberFormat = "hh:mm:ss"
    .Value = Time
End With
Call FormatTime
Call TickTock
End Sub

Private Sub FormatTime()
With ThisWorkbook.Sheets("Sheet1").Range("D4")
    .NumberFormat = "mm:ss"
    .Value = ThisWorkbook.Sheets("Data").Range("E3")
End With
End Sub

Private Sub TickTock()
With ThisWorkbook.Sheets("Sheet1").Range("D4")
    .NumberFormat = "mm:ss"
    .Value = ThisWorkbook.Sheets("Sheet1").Range("D4")
    .Value = .Value - (1 / 86400)
    If .Value <= (1 / 86400) Then
       Beep
       Call StopClock
        With ThisWorkbook.Sheets("Data").Range("H2")
            .NumberFormat = "hh:mm:ss"
            .Value = Time
       End With
       Call StartTimer
    End If
End With

NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "TickTock"

End Sub

Sub StopClock()
On Error Resume Next
Application.OnTime earliesttime:=NextTick, procedure:="TickTock", schedule:=False
On Error GoTo 0
End Sub

Here is the image of the timer:

http://img98.imageshack.us/i/timerscreenshot.gif/

timerscreenshot.gif

timerscreenshot.gif
timerscreenshot.gif


As always, thanks for any and all help.

Ralph
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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