Creating a game with Excel

Jesús
2 min readJul 23, 2023

This is not the first time I have created a game with Excel. We all know that we can do almost anything with Excel, the only limitation we have is our creativity.

Whenever we talk about a game, it seems that it is something complex to do, but in this story I want to show how in a quick way, you can make something original.

Game description

The game is very simple. We have a board in which every time we select a cell a number is revealed. If you select two consecutive cells with the same number you get a hit and the cells are revealed.

When you have the whole board with visible numbers you finish the game.

Code in VBA

The code, as we will see below, is very simple.

We will use the Worksheet_SelectionChange function that will be executed each time we select a cell.

In the Target variable we will have the selected cell, so we will be able to obtain its value and coordinates

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target = Sheets("Selection").Cells(1, 1) Then
Dim row, column As Integer
row = Sheets("Selection").Cells(1, 2)
column = Sheets("Selection").Cells(1, 3)
Target.Interior.Color = RGB(0, 255, 0)…

--

--

Jesús

I am an engineer and I love doing different projects in different programming languages, being Python and Excel the languages I use the most