Create Animated Blinking Cell in Excel VBA (Visual Basic for Applications)

Create Animated Blinking Cell in Excel VBA (Visual Basic for Applications)

In this article we will use simple Interior property and trick to create animated blinking cell background with the help of VBA Code step by step.

Step 1: create a UI like shown below:

Step 2: Name the cell containing text “www.vbaoverall.com” as “myCell”

Step 3: Insert a module in VBE and put following code:

Code example

Dim NextIteration As Date

Public Sub BlinkStart()
    NextIteration = Now + TimeValue("00:00:01")
    With Range("myCell").Interior
        If .ColorIndex <> 2 And .ColorIndex <> 3 Then
            .ColorIndex = 3
        End If
        .ColorIndex = 5 - .ColorIndex
    End With
    Application.OnTime NextIteration, "BlinkStart"
End Sub

Public Sub BlinkStop()
    Application.OnTime NextIteration, "BlinkStart", schedule:=False
    Range("myCell").Interior.ColorIndex = xlAutomatic
End Sub

Step 4: Assign each procedure to your button and Click START BLINKING to start the animation:

Next >> Change Cells Text Orientation Excel code example

Leave a Reply

Your email address will not be published.