Friday, November 13, 2026
Art Coding Education STEM

Creating a Living City Skyline in Excel with VBA Animation

When people think of Excel, they typically think of spreadsheets, budgets, dashboards, and data analysis. But Excel’s grid can also be used as a surprisingly effective canvas for creating pixel art and simple animations.

As a fun experiment, I built a nighttime city skyline entirely from Excel cells. The buildings are made of colored cells, windows light up and dim over time, and even vehicles move along the road at the bottom of the scene. Play the video capture from my Excel workbook below, and I’ll show you how you can recreate it.

The Concept

The skyline consists of:

  • Buildings created using cell fill colors
  • A night sky background
  • Illuminated windows represented by individual cells
  • VBA code that randomly turns lights on and off
  • Optional vehicle animations that continuously move across the city

The end result feels alive despite being built entirely within a spreadsheet application without having to draw anything by hand!

Step 1: Build the Skyline

Start by designing your city using cell colors.

Ideas include:

  • Dark blue cells for the night sky
  • Different shades of gray cells for buildings
  • Orange, yellow, or warm white cells for windows
  • Unicode emojis for vehicles
  • A moon (or stars if you like) for added visual interest
  • To create variety, I changed the column widths to slightly different widths.
  • To create visual depths, I overlapped some cells of same fill color over others.

Because everything is built with cells, you have complete flexibility over building heights, widths, window placement, and the overall look of the city.

Step 2: Save the Workbook as a Macro-Enabled File

Standard XLSX files do not allow VBA macros, so save the workbook as:

Excel Macro-Enabled Workbook (*.xlsm)

Close and reopen the workbook after saving.

Step 3: Open the VBA Editor

Press: Alt + F11

Then: Insert → Module

A blank new module will appear under the workbook’s VBA project where you’ll add VBA code.

Step 4: Add the Skyline Animation Code

The animation works by maintaining a list of window cells and randomly selecting one during each cycle.

The selected window either:

  • Turns off (dark gray), or
  • Turns on using one of two illuminated colors

The code continuously schedules itself using Application.OnTime, creating a simple but effective animation loop.

Be sure this line matches the actual worksheet name:

If your worksheet tab is named differently, update the code accordingly.

Step 6: Run the Animation

Press: Alt + F8

Select: StartSkyline

Then click Run.

The city lights will begin turning on and off automatically.

To stop the animation:

Alt + F8 → StopSkyline

Troubleshooting

One issue that caught me off guard was that pressing the Run button inside the VBA editor executes whichever procedure currently contains the cursor.

If nothing appears to happen:

  1. Press Ctrl + G to open the Immediate Window.
  2. Place the cursor inside the StartSkyline() procedure.
  3. Press F5.

This ensures the correct procedure starts.

Adding Moving Vehicles

To make the skyline feel even more alive, I added a simple vehicle animation.

The road occupies Row 21.

Vehicles are represented using Unicode emoji characters such as:

  • 🚗
  • 🚕
  • 🚌

Each animation cycle shifts the row one cell to the left.

When a vehicle leaves the scene on the left side, it reappears on the far right, creating an endless loop.

Vehicle Animation Code

Call the procedure from within AnimateSkyline() before the Application.OnTime line.

Making Vehicle Movement More Realistic

Initially, the vehicles moved every time the windows updated. This worked, but the traffic felt a bit mechanical. A more natural approach is to move the vehicles only some of the time.

For example:

Extending the Project

Once the basics are working, there are plenty of ways to enhance the skyline:

  • Add aircraft warning lights on tall buildings
  • Create eastbound and westbound traffic lanes
  • Add stars that twinkle
  • Simulate office towers shutting down after business hours
  • Add apartment buildings with different occupancy rates
  • Create sunrise and sunset transitions
  • Record the animation as an MP4 and use it in presentations or videos

Final Thoughts

This project started as a simple experiment but turned into a great reminder that Excel is much more flexible than most people realize. With a little creativity, worksheet cells become pixels, VBA becomes an animation engine, and a spreadsheet becomes a living city. This was a quick example of one implementation, but you can spend a vast amount of energy and time to make this type of creations epic!

Sometimes the most enjoyable Excel projects are the ones that have nothing to do with accounting, dashboards, or data at all 🤔.

You may also be interested in:

Back To Top