Okay, that's very easy.
Make a new file and copy all code below my name into the code module of the worksheet.
IMHO it's better for your purpose, because you can switch to other sheets if the counter is running.
Execute Sub Example_ShowTimer once, you did not use that code later, it's just for this example. The Change event should fire and the cell A2 is colored green.
Execute Sub ShowTimer. The counter starts, the cell is colored red by the Change event.
This sub is executed every second and updates the counter. If the endtime is reached, it stores 0 into the counter, the Change event fires and the cell is colored green again. Done.
Andreas.
Option Explicit
Dim TimerCounter As Range
Dim EndTime As Double
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address(0, 0)
'Counter cell changed?
Case "A2"
If Target = 0 Then
'Green
Target.Interior.Color = 5287936
Else
'Red
Target.Interior.Color = 255
End If
End Select
End Sub
Sub Example_ShowTimer()
'Setup a scenario for ShowTimer
'The cell with the initial value
With Range("A1")
.NumberFormat = "[m]:ss"
.Value = TimeSerial(0, 0, 10)
End With
'The cell to show the countdown
With Range("A2")
.NumberFormat = "[m]:ss"
.Value = 0
End With
End Sub
Sub ShowTimer()
'Already initialized?
If TimerCounter Is Nothing Then
'Setup the cell to show the countdown
Set TimerCounter = Range("A2")
'Copy the start value
'Note:
' This raises the Change event in the worksheet!
' You can color the cells here or in the change event
TimerCounter = Range("A1")
'Calculate the endtime
EndTime = Now() + TimerCounter
'Force excel to call ourself in one second
Application.OnTime Now + TimeSerial(0, 0, 1), _
Me.CodeName & ".ShowTimer"
Exit Sub
End If
'To avoid an event every second!
Application.EnableEvents = False
'Store the remaining time into the cell
TimerCounter = EndTime - Now()
'Enable the events
Application.EnableEvents = True
'Countdown complete?
If TimerCounter <= 0 Then
'Be sure the cell shows zero
'Note:
' This raises the Change event in the worksheet!
' You can color the cells here or in the change event
TimerCounter = 0
'Prepare for the next run
Set TimerCounter = Nothing
Else
'Force excel to call ourself in one second
Application.OnTime Now + TimeSerial(0, 0, 1), _
Me.CodeName & ".ShowTimer"
End If
End Sub