Forum Discussion
lobo114
Dec 04, 2024Brass Contributor
Using VBA to make a cell blink
I am trying to figure out how to use VBA to make a cell blink in Excel. In the attached example, if a cell in column G is over 45 days old from the date in column F, I would like the corresponding ce...
- Dec 04, 2024
Just to show you how annoying it is, I have attached an example.
Kidd_Ip
Dec 05, 2024MVP
How about this:
Dim NextBlink As Double
Sub StartBlink()
NextBlink = Now + TimeValue("00:00:01")
Application.OnTime NextBlink, "BlinkCell"
End Sub
Sub BlinkCell()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name
Dim cell As Range
For Each cell In ws.Range("G2:G" & ws.Cells(ws.Rows.Count, "G").End(xlUp).Row)
If cell.Value <> "" And DateDiff("d", cell.Value, Now) > 45 Then
With ws.Cells(cell.Row, "D")
If .Interior.Color = RGB(255, 255, 255) Then
.Interior.Color = RGB(255, 0, 0)
Else
.Interior.Color = RGB(255, 255, 255)
End If
.Font.Color = RGB(255, 255, 255)
End With
End If
Next cell
StartBlink
End Sub
Sub StopBlink()
On Error Resume Next
Application.OnTime NextBlink, "BlinkCell", , False
End Sub