I created a hangman game using Excel VBA for fun, and thought I would post it here for all budding Excel VBA learners to look at.
I find creating games, quizzes and sports spreadsheets an enjoyable way of keeping my Excel skills fresh, and to develop them further.
The game asks you to guess a letter to complete the phrase. A hint is provided for a little help, and the phrase will be related to music, sports, people, film or geography.
The spreadsheet is unprotected so you can check out the code and play around it with it further.
The VBA used to create this hangman game includes;
- Dynamic arrays.
- Creating a userform.
- Module scoped variables.
- Lots of text work including functions such as Left and StrConv.
- Lots of For Loops, IF statements and a Select Case statement.
Download the Excel Hangman game
I also have a special Christmas version of my Hangman game in Excel to download.
In modern version of Excels, when downloading macro enabled spreadsheets, you will often need to unblock the files to allow the macros to run.
Do this by;
- Locate the Excel file on your computer (probably the Downloads folder).
- Right-click on the file and click Properties.
- Check the Unblock box and click OK.
Let me now how you do? I want to see some high scores 😉
Want to improve your Excel VBA skills? All the techniques used to create this hangman game are covered in our Excel VBA course.
Avril says
Hi,
I downloaded the game but where are the questions?
Thanks.
Avril says
Never mind, I found it.
ps. it hurts my brain looking at your codes how does one learn this stuff in the first place O_O
computergaga_blog says
Using our online Excel VBA course 🙂
Really it is a case of watching tutorials, reading articles and then getting stuck in and practising.
Mr Ian Humphreys says
Download link takes me to a Error 404
Alan Murray says
This has now been fixed, Ian.
Beepee says
Hi.
Downloaded fine and had a game – however the hanged man image does not erase on clicking New Game button. Only the head is made invisible!
A small change to the Select case routine:
Place all of the Case: 6 code in the last position and the right leg is made visible before ending the game.
Alan Murray says
I’ll check this out. It is a very old application, about 10 years, so I don’t recall the code that was used.