Computer >> Computer tutorials >  >> Software >> Office

Master Text Animation in Excel: Two Proven Methods

Method 1 – Scrolling Text Animation

Master Text Animation in Excel: Two Proven Methods

  • Open the Visual Basic Window by pressing Alt+F11.
  • Insert a new module by going to Insert and clicking on Module.

Master Text Animation in Excel: Two Proven Methods

  • 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

Master Text Animation in Excel: Two Proven Methods

️ How Does the Code Work?

  • Start_Text_Scroll subroutine scrolls the text stored in cell C4.
  • It creates a loop that shifts the text from left to right.
  • Adjust the speed by changing the value of AA.
  • To stop scrolling, use the Stop_Scrolling subroutine.
  • Add buttons for starting and stopping scrolling:
    • Insert shapes (e.g., rectangles) from the Insert tab.

Master Text Animation in Excel: Two Proven Methods

    • Enter Start Scrolling inside one shape.

Master Text Animation in Excel: Two Proven Methods

    • Assign the Start_Text_Scroll macro to this shape.

Master Text Animation in Excel: Two Proven Methods

    • Click OK.

Master Text Animation in Excel: Two Proven Methods

    • Repeat for the Stop Scrolling button.

Master Text Animation in Excel: Two Proven Methods

  • Use the buttons to start and stop scrolling the Text message.

Master Text Animation in Excel: Two Proven Methods

Method 2 – Blinking Animated Text

  • Draw Text Boxes
    • Go to the Insert tab and select Text and click on Text Box.

Master Text Animation in Excel: Two Proven Methods

    • Draw a text box of your preferred size.

Master Text Animation in Excel: Two Proven Methods

    • Enter the text you want to make blink.

Master Text Animation in Excel: Two Proven Methods

  • Add Empty Text Boxes
    • Create additional text boxes of similar shapes and sizes.

Master Text Animation in Excel: Two Proven Methods

  • Rename Text Boxes
    • Rename the text boxes as follows: TextBox 1, TextBox 2, and so on.

Master Text Animation in Excel: Two Proven Methods

  • Overlay Text Boxes
    • Arrange all text boxes so they overlap and appear as a single box.

Master Text Animation in Excel: Two Proven Methods

  • VBA Code
    • Open the VBA editor by pressing Alt+F11.
    • Insert a new module (Insert > Module).

Master Text Animation in Excel: Two Proven Methods

  • 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

Master Text Animation in Excel: Two Proven Methods

️ How Does the Code Work?

  • The Blink subroutine brings text boxes to the front one by one (from TextBox 1 to TextBox 5) using the ZOrder command.
  • Error handling ensures that the first text box remains visible.
  • 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

Master Text Animation in Excel: Two Proven Methods

️ How Does the Code Work?

  • When data is inserted into cell B4, Excel calls the Blink module.

Master Text Animation in Excel: Two Proven Methods

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
Get FREE Advanced Excel Exercises with Solutions!