PDA

View Full Version : How to make an Excel Cell Blink?



ExcelBaap
07-26-2017, 09:28 PM
To be able to achieve this, we need to write some code in the Worksheet module that will trigger an action when any change happens.

Here's the code to be written in Worksheet module:


Option Explicit
Public CellCheck As Boolean

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

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


Here's the code that is to be written in a 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


You may put two buttons on the worksheet - one for starting the blinking process and one for stopping it. Once the button is inserted, simply right click on it and click on 'Assign Macro' and select the appropriate macro.

I'm also attaching the worksheet.

5