If I have a time value in cell A1 as 00:00, how can I use VBA to make the cell blink when the current time is 2 hours greater than A1, and stop when cell has no value or empty? Here is the homework I've done. I've never really messed with VBA so forgive my ignorance. Maybe I can use a variation of this, editing the "If Range("A1") = "1" in the code?
MODULE
Option Explicit
Public RunWhen As Double
Sub StartBlink()
If Range("A1").Interior.ColorIndex = 3 Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = 3
End If
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink", , True
End Sub
Sub StopBlink()
Range("A1").Interior.ColorIndex = xlAutomatic
Application.OnTime RunWhen, "StartBlink", , False
End Sub
CODE
Option Explicit
Public CellCheck As Boolean
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Change the IF statement and cell range to what you need
If Range("A1") = "1" And CellCheck = False Then
Call StartBlink
CellCheck = True
ElseIf Range("A1") <> "1" And CellCheck = True Then
Call StopBlink
CellCheck = False
End If
End Sub
Bookmarks