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.
Option Explicit
Public NextRun As Date
Public SkylineRunning As Boolean
Sub StartSkyline()
SkylineRunning = True
Randomize
AnimateSkyline
End Sub
Sub StopSkyline()
SkylineRunning = False
On Error Resume Next
Application.OnTime NextRun, “AnimateSkyline”, , False
End Sub
Sub AnimateSkyline()
Dim ws As Worksheet
Dim Windows As Variant
Dim WindowCell As Range
Dim idx As Long
If SkylineRunning = False Then Exit Sub
Set ws = ThisWorkbook.Worksheets(“Skyline”)
Windows = Array( _
“C13”, “C15”, “E15”, _
“C17”, “G17”, “F19”, _
“H19”, “F16”, “J11”, _
“K10”, “J13”, “L18”, _
“O13”, “O15”, “O17”, _
“Q17”, “R16”, “R19”, _
“T18”, “X10”, “X14”, _
“X18”, “X19”, “V16”, “V12” _
)
idx = Int(Rnd() * (UBound(Windows) + 1))
Set WindowCell = ws.Range(Windows(idx))
If WindowCell.Interior.Color = RGB(89, 89, 89) Then
If Rnd() < 0.5 Then
WindowCell.Interior.Color = RGB(251, 226, 213)
Else
WindowCell.Interior.Color = RGB(255, 170, 50)
End If
Else
WindowCell.Interior.Color = RGB(89, 89, 89)
End If
NextRun = Now + TimeValue(“00:00:01”)
Application.OnTime NextRun, “AnimateSkyline”
End Sub
Step 5: Match the Worksheet Name
Be sure this line matches the actual worksheet name:
Set ws = ThisWorkbook.Worksheets(“Skyline”)
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:
- Press Ctrl + G to open the Immediate Window.
- Place the cursor inside the StartSkyline() procedure.
- 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
Sub MoveVehicles()
Dim ws As Worksheet
Dim Road As Range
Dim Values As Variant
Dim i As Long
Set ws = ThisWorkbook.Worksheets(“Skyline”)
Set Road = ws.Range(“B21:Y21”)
Values = Road.Value
Dim LastVehicle As Variant
LastVehicle = Values(1, 1)
For i = 1 To UBound(Values, 2) – 1
Values(1, i) = Values(1, i + 1)
Next i
Values(1, UBound(Values, 2)) = LastVehicle
Road.Value = Values
End Sub
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:
If Rnd < 0.6 Then
MoveVehicles
End If
This creates roughly a 60% chance that vehicles move during each animation cycle, producing a less predictable and more lifelike effect.
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: