logo
search
VBA & Macro Problems

How to Animate Excel Shapes and Text Boxes with VBA

Amos GikundaAmos Gikunda Sep 25, 2026 869 views

Question details

The user wants to animate named text boxes and shapes in Excel by using VBA to loop through a data table, change colors, and update text, and then export the resulting animation as a video.

How to Animate Excel Shapes and Text Boxes Using VBA
Product
Excel
Device & OS
not provided
Scenario
Dynamically animating worksheet shapes based on table data and capturing the output.
Observed behavior
Requires a functional VBA macro to match table rows to shape names, iteratively update shape colors and text, and export the visual result as an MOV or video file.
Before you start

Ensure your workbook is saved as an Excel Macro-Enabled Workbook (.xlsm) and that the Developer tab is enabled in your Excel ribbon so you can access the VBA editor.

Solution 1Recommended

Write a VBA Macro to Loop Through Table Data and Update Shapes

Create a VBA script that reads table rows, matches text box names, and updates their text and colors iteratively with a built-in delay to create an animation effect.

To create a visible animation effect instead of an instant final result, your code must force the screen to update during the execution cycle. Using the DoEvents command or Application.Wait allows the screen to refresh as each shape gets modified.

1
Open the VBA Editor

Navigate to the Developer tab on the Excel ribbon and click on Visual Basic to open the VBA editor window.

2
Insert a New Module

Click Insert > Module from the top menu inside the VBA editor to create a new blank script area for your animation code.

3
Write the Animation Loop

Write a For Each loop that iterates through your specific table data. Inside the loop, use ActiveSheet.Shapes(cell.Value) to reference the shape by name. Update properties like .TextFrame.Characters.Text and .Fill.ForeColor.RGB.

4
Add Screen Refresh Command

Include the DoEvents command directly inside your loop just after the shape properties are updated. This forces Excel to redraw the screen, making the shape changes visibly appear as an animation.

Write a VBA Macro to Loop Through Table Data and Update Shapes
Important: Ensure that the shape names specified in your table exactly match the actual names of the text boxes on your worksheet, which can be verified using the Selection Pane.
Powerful Macro Support

Run and Manage VBA Macros with WPS Spreadsheet

WPS Office provides robust support for VBA macros, allowing you to seamlessly execute your scripts to animate shapes, automate repetitive data processing, and manage your worksheets with ease.

  1. 1. Open Macro-Enabled File: Launch WPS Spreadsheet and open your .xlsm file containing the shape animation code.
  2. 2. Access the Developer Tab: Navigate to the Developer tab on the top ribbon to access the macro tools.
  3. 3. Run the Animation: Click on 'Macros', select your animation script from the list, and click 'Run' to watch your shapes update.
Fully compatible with Microsoft Excel .xlsm and .xlsb macro formatsBuilt-in VBA editor for writing, debugging, and running shape animationsLightweight design ensures smooth macro execution without system lagAdvanced shape formatting and data table management tools
microsoft office alternative - wps office

Frequently Asked Questions

Why are my Excel shapes not updating visibly during the VBA loop?

VBA loops often execute much faster than the screen can refresh. Ensure you include the DoEvents command within your loop. This command temporarily yields execution so the operating system can process other events, forcing Excel to redraw the screen and display the changes iteratively.

Can I export an Excel animation directly to MP4 using VBA?

No, Excel does not have a built-in capability to natively export or record VBA macro executions as video files like MP4 or MOV. You must use third-party screen recording software to capture the animation as it happens on your screen.

How do I match table values to specific text box names in VBA?

In your VBA code, you can use the syntax ActiveSheet.Shapes(cell.Value) where cell.Value is a variable pointing to the cell containing the exact string name of the shape you wish to target. You can verify and edit shape names using the Selection Pane under the Page Layout tab.