[Excel animation] Christmas tree
- yuji fukami
- 6 days ago
- 6 min read
overview
This time, we will introduce a Christmas animation created using Excel VBA.
Snow falls on the cell, the color gradient of the letters "Merry Christmas" slowly changes, and the Christmas tree lights rotate and softly twinkle - the result is a work with a sense of movement.
First, please watch the video 👇
PR
This article was created as part of the 2025 Advent Calendar for the Discord community "Excel-Fun.xls*."
This is a fun and informative community for Excel and VBA lovers, so please join us!
↓"Excel-Fun.xls* Participation Link"

Technical explanation (Christmas tree)
This blog will focus on the following technical points:
Excel animation basics
Color change animation of gradient text (Merry Christmas)
Snowing effect mechanism (using existing code)
Christmas tree lighting arrangement
Expressing blinking with lighting "blurring effect"
This article summarizes ideas for using Excel as a "canvas" to create animations, rather than as a "static spreadsheet software."
1. Excel animation basics
First, we will explain the basics of Excel animation using the animation below of a circular shape rotating and moving.
The video has a start button, "Run Animation" and a "Stop" button. When you press the "Run Animation" button, the circular shape starts rotating and when you press the "Stop" button, it stops.
The actual code is explained below:

As shown in the diagram above, the animation process is divided into three main steps.
① Shape reference and initial settings
First, get the circle shape you want to move (in this example, the name is "Circle"),
Set parameters such as the center position of rotation, radius, and rotation speed.
The value set here will be used in subsequent coordinate calculations.
This determines "which position will be the center and how much it will move."
② Turn off the stop trigger and start the animation
To control the animation,
We have prepared a stop flag (Boolean) called PriJudgeStop.
Animation Start: False
If the stop button is pressed: True
This is how animations are controlled to be turned on and off.
By making sure this flag is False at the start,
The Do-Loop loop will continue to run correctly.
③ Animation processing using Do-Loop
The main process is a repeat of the Do-Loop.
Each loop corresponds to one frame.
Within the loop, the following steps are executed in order:
Next, we will explain in detail the animation process inside the Do-Loop.

The processing in the red box in the figure is done in Do ~ Loop
Moving and transforming shapes
Reflection on the screen (DoEvents)
Determining the stop process
It has a simple structure that simply repeats these three steps over and over.
① Moving and transforming shapes
First, at the beginning of the loop, we change the position and shape of the circle shape.
Here, Left, Top, etc. are rewritten based on the coordinate calculation results, and the "movement and transformation for the next frame" is determined. (We won't go into detail about the contents of the coordinate calculation here.)
② Reflection on the screen (DoEvents)
Then, call DoEvents to make the changes visible on the screen.
Animation is not visible when you simply change a value; it is only recognized as "movement" when the value is changed, drawn on the screen, changed again, and so on, repeated at high speed.
In this code, DoEvents is executed twice in succession to improve drawing stability. If the movement is choppy, you can adjust the drawing timing by increasing or decreasing the number of DoEvents.
③ Determining whether to stop the process
Finally, we check to see if the stop button was pressed.
On the stop button side, PriJudgeStop = True is set when it is clicked.
This flag is checked each time within Do ~ Loop, and if PriJudgeStop = True, the loop is exited with Exit Do and the animation process is terminated.
The above three stages,
"Movement/Transformation → Screen Reflection → Stop Judgment"
By repeating the above in a Do Loop, continuous animation is achieved on the Excel sheet.
In this work, "Christmas Tree," we are simply doing something more complex with "① Moving and transforming shapes," but the structure of the Excel animation is the same as the one above.
2. Gradient text color change
The text "Merry Christmas" displayed at the bottom of the screen is set to a gradient (two colors) using Excel's "Text Fill" feature.
First, in the formatting pane on the right,
Type: Gradient
Branch points: 2 (left color, right color)
This is the same as normal shape formatting, and no VBA is used.

2-1. Rewrite two gradient colors from VBA
During the animation, these two colors are rewritten every frame from VBA.
In the code, for the logo shape
TextFrame2 → TextRange → Font → Fill → GradientStops(1),(2).Color.RGB
This directly updates the RGB values of the "left color" and "right color" of the gradient by going through a slightly more in-depth property.
GradientStops(1).Color.RGB ... Left color
GradientStops(2).Color.RGB ... Right color
By substituting the colors calculated according to the current frame number K into these two places, the color of the entire logo will slowly change.
2-2. Color calculation is separated into two functions
The actual color calculation is
Cal_Logo Color 1
Cal_Logo Color 2
The internal structure of both functions is almost the same,
Determine the minimum and maximum ranges for each of R, G, and B.
Use a trigonometric function (Cos) to cycle through the range
Finally, return the result as a single color in RGB (R, G, B) format.
This is the process.

Since the number of frames for one cycle (20 in this case) is specified, the color will return to its original color every 20 frames, creating a looping color change.
2-3. The two color cycles are shifted by 1/3
The only difference between Cal_Logo Color 1 and Cal_Logo Color 2 is that the timing of the cycle (wave) is shifted by 1/3 .
Left color: Cycle starts at 0
Right color: Shift the start of the cycle by 1/3
With this image in mind, the "phase" of the trigonometric function has been slightly changed.
This means:
The color on the left side starts to change,
A little later, the color on the right follows.
This creates a shift in the colors, creating a more gradational effect , rather than the two colors changing at the same time.
3. Snowing animation
The snow that falls across the screen is based on the Excel animation "Snow Falling" that I created previously.
For details, please refer to the link below.
4. Christmas tree lighting arrangement
The tree lights are made from a number of small circular shapes.
The idea is,
Creating a virtual "cone" in three-dimensional space
Lights are evenly spaced on the surface of the cone
Project it to 2D coordinates on an Excel sheet
These are the steps.
Although the Excel file shows a flat surface, the 3D coordinates are calculated and converted into the "X axis (left and right)" and "Y axis (height)" to create a three-dimensional illuminated tree .
This calculation uses three-dimensional vectors and rotation matrices, but since it would take too long, I will omit the details this time.
5. Recreate the twinkling of lights with a blur effect
The soft light of the lighting can be achieved by using the Soft Edge effect that can be set for shapes.
This is expressed by gradually changing the "blur size" during the animation.

In Excel's Shape Formatting, there is an option for each shape called [Format Shape → Blur → Size] . Normally, this function only sets a fixed value, but in this case, the blur size value itself is changed dynamically from VBA .
In animation processing, for each frame
Calculate the “blur amount” depending on the current frame number
Assign the calculated value to the shape's SoftEdge.Radius
In this way, the strength of the blur is slowly adjusted.
The function used is a simple trigonometric function (periodic function), which gives
The moment when it looks bright
The moment the light softly fades
The moment it gets bright again
This creates a natural, breathing change in the light.
By directly animating the amount of blur, even a static circular shape can be made to look like blinking LEDs or magical twinkling lights .
summary
In this animation work,
Periodic expressions using trigonometric functions
Gradient color change over time
3D to 2D projection calculation
Animating shape blur effects
It combines a variety of expressions that can also be achieved in Excel , such as:
Excel VBA can be used not only for business automation but also for creating interactive works and performances like this one.
We will continue to introduce fun creations using VBA and technical mechanisms, so please look forward to them.


Comments