VBA – Puzzle Game in Excel

So, in this post I will show you a puzzle game in MS Excel – it is like the old one, the kids from the ’90s used to have, before we had PCs.

So, the excel file is here, just open it and enable macros and the game will start. By the way, try to beat my record on the picture below 🙂


How does it work? With the openning, the following macro is executed:

It is located in “This Workbook”. Its only function is to start the subprocedure “PlayGame”, which is located in Module 1. The subprocedure shows UserForm1 (with the beautiful logo of this website). In the form the size of the buttons is calculated. The trick in the game is, that it actually does not swap the buttons in the game, but only the captions of the button, and thus the player has the illusion that the buttons are swaped. This is achieved with the code:

The last trick is in the movement counter. This part of the code is hidden in the Class Modules. With Every change of the puzzle, the following code is executed:

In order to stimulate a little conversation with the user, I have added some messageboxes on the 50th, 80th and the 90th move with the following code:

So, I think that you can download the game and play with it as much as you like! Have fun!

The Puzzle is here.