Method 1 – Scrolling Text Animation
- Open the Visual Basic Window by pressing Alt+F11.
- Insert a new module by going to Insert and clicking on Module.
- Copy the following code and paste it into the new module:
' Scrolling Text
Sub Start_Text_Scroll()
My_Value = ActiveSheet.Range("C4").Value
Final_Value = WorksheetFunction.Rept(My_Value, 1)
Do
For initial = 1 To Len(Final_Value)
Length = Len(Final_Value) - 1
DoEvents
For AA = 1 To 10000000
AA = AA + 1
Next
Range("B6") = Mid(Final_Value, initial, Length) & Left(Final_Value, initial - 1)
Next
Loop
End Sub
Sub Stop_Scrolling()
End
End Sub
️ How Does the Code Work?
- Add buttons for starting and stopping scrolling:
- Insert shapes (e.g., rectangles) from the Insert tab.
-
- Enter Start Scrolling inside one shape.
-
- Assign the Start_Text_Scroll macro to this shape.
-
- Click OK.
-
- Repeat for the Stop Scrolling button.
- Use the buttons to start and stop scrolling the Text message.
Method 2 – Blinking Animated Text
- Draw Text Boxes
- Go to the Insert tab and select Text and click on Text Box.
-
- Draw a text box of your preferred size.
-
- Enter the text you want to make blink.
- Add Empty Text Boxes
- Create additional text boxes of similar shapes and sizes.
- Rename Text Boxes
- Rename the text boxes as follows: TextBox 1, TextBox 2, and so on.
- Overlay Text Boxes
- Arrange all text boxes so they overlap and appear as a single box.
- VBA Code
- Open the VBA editor by pressing Alt+F11.
- Insert a new module (Insert > Module).
- Enter the following code:
Sub Blink()
On Error GoTo skip
Do While Range("B4").Value = "Blink"
For txtbx = 1 To 5
ActiveSheet.Shapes("TextBox " & txtbx).ZOrder msoBringToFront
DoEvents
Next txtbx
Loop
skip:
ActiveSheet.Shapes("TextBox 1").ZOrder msoBringToFront
Exit Sub
End Sub
️ How Does the Code Work?
- Worksheet Code
- In the worksheet code, enter:
Private Sub Worksheet_Change(ByVal Tgt As Range)
If Tgt = Range("B4") Then
Call Blink
End If
End Sub
️ How Does the Code Work?
Things to Remember
- In the 2nd method, remember to correctly rename and align the text boxes for smooth animation
Download Practice Workbook
You can download the practice workbook from here:
Related Articles
- How to Create Animated Bar Chart Race in Excel
- How to Create Animated Charts in Excel
- VBA Animation in UserForm