How to Animate Excel Shapes and Text Boxes with VBA
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.

- 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.
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.
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.
Navigate to the Developer tab on the Excel ribbon and click on Visual Basic to open the VBA editor window.
Click Insert > Module from the top menu inside the VBA editor to create a new blank script area for your animation code.
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.
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.

Record the Excel Animation as a Video
Since Excel does not have a native feature to export VBA animations as video files, you must use a screen recording tool to capture the execution.
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. Open Macro-Enabled File: Launch WPS Spreadsheet and open your .xlsm file containing the shape animation code.
- 2. Access the Developer Tab: Navigate to the Developer tab on the top ribbon to access the macro tools.
- 3. Run the Animation: Click on 'Macros', select your animation script from the list, and click 'Run' to watch your shapes update.

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.




