2.3 Tic Tac Toe in Excel

Let’s create a digital tic tac toe game in Microsoft Excel!

We’ll use Excel in desktop mode, add the developer tab, and command buttons. It’ll be FUN! Let’s do it!

Here’s the steps to do it:

  1. Open Excel in desktop mode.
  2. File Save As, TicTacToe.xlsm (Macro Enabled Workbook)
  3. Add developer tab (right click on blank space in ribbon)
  4. Developer’s Tab, View Code
  5. Insert Tab, Insert UserForm
  6. Right click inside the form and click on Properties (or F4 brings up Properties)
    1. Change Properties of the Form
      1. Change name to tttfrm
      1. Change caption to tic-tac-toe
      1. Change height to 270, change width to 300
  7. Insert commandbutton to userform (ttfrm) by clicking View Tab then Toolbox.
    1. Change Caption to blank
    1. Change height to 55, change width to 55
    1. Change font size to 22
  8. Copy commandbutton 8 more times to make a Tic Tac Toe board
  9. Press F5 to test your work, then close it
  10. Click View Code, double click tttfrm
  11. Double Click the first command button, insert this code within the sub:

12. Do the rest, just copy-paste the code and change it to CommandButton numbers from 1 to 2 then 3, and so on. So “CommandButton2.Caption…”

13. Then check it out as you go by hitting F5.

14. Create a Restart Button with another commandbutton

a. Click in one of the command buttons, then View, Toolbar, then CommandButton

b. Draw another commandbutton

i. Change caption to “Restart”

ii. Double click in it and paste this code in the sub:

15. Run F5 and see if the Restart button works

16. Create a Start Tic Tac Toe button

a. Click Developer’s Tab, Controls, Insert, Under ActiveX Controls find the CommandButton

b. Right Click CommandButton, Click Properties, Change Caption to “Start Tic Tac Toe”.

c. Double click the button, (design mode must be enabled). Copy paste this code in the sub: Tttfrm.show

d. Close the coding window, turn off design mode

Here are a few diagrams showing the different parts of Microsoft Excel. Be sure you know each of these vocabulary words. We’ll have some Blooket Games at the end!

Try playing these Blooket sets now that you’ve used Excel a little bit.

Spreadsheet basics | Blooket

Learn By Doing – MOS Excel 2016_Lesson 1 | Blooket

We hope you enjoyed learning about creating games in Microsoft Office!