How I create a viral word game in Excel

https://www.profitableratecpm.com/f4ffsdxe?key=39b1ebce72f3758345b2155c98e6709c

I love using Excel for things outside boring accounting. Building a fully functional, reusable, and shareable Wordle clone is one of these things. What’s more, it’s a fun, unique way to master fundamental Excel tools.

This method uses VBA macros

The main step in this guide uses VBA macros to handle the complex Wordle guessing sequence and scoring logic. This ensures the player has the most reliable experience, as it doesn’t require them to change any of their core Excel settings. However, don’t worry if you don’t know how to write VBA code, as you can simply copy and paste mine!

When the player opens the macro-enabled file, they’ll see a security warning ribbon at the top of their Excel screen. At this point, they must click “Enable Content” for the game to work as expected. If they don’t, the board will be static and won’t score their guesses.

Both you and the players who’ll get a copy of your game must use the desktop version of Microsoft Excel.

OS

Windows, macOS, iPhone, iPad, Android

Free trial

1 month

Microsoft 365 includes access to Office apps like Word, Excel, and PowerPoint on up to five devices, 1 TB of OneDrive storage, and more.


Step 1: Saving the macro-enabled file

This step prepares your workbook for VBA. Open a new Excel workbook, and click File > Save As > Browse.

The File menu in Microsoft Excel, with Save As and Browse selected.

Choose a location for your file, and in the Save As Type field, select “Excel Macro-Enabled Workbook.” Then, name the file, and click “Save.”

An Excel file named Wordle is saved as a Macro-Enabled Workbook.

Step 2: Setting up the dictionary and canvas

Next, you need to create a dictionary of valid words and create the Wordle game board.

Add a new worksheet (“+”), and double-click the new sheet tab to rename it WordList. Press Enter to confirm.

A new Excel worksheet is added to the current workbook and called WordList.

Find a five-letter word list, copy all the words, and paste them (using Ctrl+Shift+V) into cell A1 in the WordList sheet. Then, check for and remove exact duplicates by selecting column A and clicking “Remove Duplicates” in the Data tab.

A list of words in column A of an Excel worksheet, with the Remove Duplicates tool in the Data tab selected.

Next, move back to the game worksheet (Sheet1), select all the cells (Ctrl+A), and change the cell widths to 65px by clicking and dragging the boundary between two column headings.

A blank Excel worksheet, with all cells selected, and the column widths reduced to 65 pixels.

Repeat this process for the rows to make all cells square.

Now, input a secret five-letter word into cell A1 in block capitals. Then, select cells B3 to F8, change the font size to 36pt, and center-align the text vertically and horizontally via the Home tab. Finally, add an outside border.

Some cells in Excel are selected, and their font size is changed to 36pt, an outside border is added, and the vertical and horizontal alignments are set to Center.

Press Ctrl+S to save the file.

A phone with Excel open, some office objects around and a TV in the background.

Excel Isn’t Just for Accountants: 4 Ways I Use It In My Daily Life

Excel is a great tool for staying organized in your busy life.

Step 3: Creating the game’s mechanics

The macro is the engine room of your game. It handles all the scoring, colors, and letter logic automatically.

Right-click the “Sheet1” tab and click “View Code.”

An Excel worksheet tab's right-click menu is expanded, and View Code is selected.

In the VBA Editor window, double-click “Sheet1 (Sheet1)” under Microsoft Excel Objects, and copy and paste the code below into the blank module area to the right.

Sheet1 is selected in the VBAProject area of Excel's VBA window, and the module area is highlighted.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim GuessRow As Long
Dim SecretWord As String
' Only run if the changed cell is the F-column (the fifth letter of a guess)
If Not Intersect(Target, Me.Range("F3:F8")) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
' CRITICAL: Unprotect the sheet to allow the macro to change colors and lock status
If Me.ProtectContents Then Me.Unprotect "YOUR_PASSWORD"
GuessRow = Target.Row
' 1. Get Secret Word and Guess
SecretWord = UCase(Me.Range("A1").Value)
' Concatenate the 5 cells into a single string
Dim InputWord As String
Dim j As Long
For j = 2 To 6 ' Loop through columns B to F
InputWord = InputWord & Me.Cells(GuessRow, j).Value
Next j
Dim GuessWord As String
GuessWord = UCase(InputWord)
' 2. Check if valid word (using COUNTIF trick)
Dim WordCount As Long
WordCount = Application.WorksheetFunction.CountIf( _
Sheets("WordList").Range("A:A"), GuessWord)
If WordCount = 0 Then
' Handle invalid word (Not in word list)
MsgBox "Not in word list! Please try again.", vbExclamation
Me.Range("B" & GuessRow & ":F" & GuessRow).ClearContents
Else
' NEW CHECK: Check for duplicate entry
Dim r As Long
Dim DuplicateFound As Boolean
DuplicateFound = False
' Loop through all *previous* guess rows (from row 3 up to the current row - 1)
For r = 3 To GuessRow - 1
' Concatenate the word from the previous row for comparison
Dim PreviousWord As String
Dim k As Long
For k = 2 To 6 ' Columns B to F
PreviousWord = PreviousWord & Me.Cells(r, k).Value
Next k
' Compare the uppercase current guess (GuessWord) with the previous guess
If GuessWord = UCase(PreviousWord) Then
DuplicateFound = True
Exit For
End If
PreviousWord = "" ' Reset for the next loop iteration
Next r
If DuplicateFound Then
MsgBox "You already guessed that word! Please try again.", vbExclamation
Me.Range("B" & GuessRow & ":F" & GuessRow).ClearContents
' Restore settings and exit sub after duplicate is cleared
Application.EnableEvents = True
Application.ScreenUpdating = True
Me.Protect "YOUR_PASSWORD"
Exit Sub
End If
' 3. Core Wordle Scoring Logic (Sets the cell colors directly)
Dim i As Long
Dim Letter As String
Dim ClaimedLetters As String
ClaimedLetters = SecretWord ' Start with all letters available
' Pass 1: Check for GREEN (Correct Position)
For i = 1 To 5 ' Columns 2 (B) to 6 (F)
' FIX: Convert cell content to uppercase for scoring comparison
Letter = UCase(Me.Cells(GuessRow, i + 1).Value)
If Mid(SecretWord, i, 1) = Letter Then
Me.Cells(GuessRow, i + 1).Interior.Color = RGB(106, 170, 100) ' Green
Mid(ClaimedLetters, i, 1) = "#" ' Use placeholder to claim the letter
End If
Next i
' Pass 2: Check for YELLOW/GRAY
For i = 1 To 5
' FIX: Convert cell content to uppercase for scoring comparison
Letter = UCase(Me.Cells(GuessRow, i + 1).Value)
' Only score if not already colored GREEN
If Me.Cells(GuessRow, i + 1).Interior.Color <> RGB(106, 170, 100) Then
' Search the remaining (non-Green) available letters
If InStr(1, ClaimedLetters, Letter) > 0 Then
Me.Cells(GuessRow, i + 1).Interior.Color = RGB(201, 180, 88) ' Yellow
' Claim this yellow letter instance
Mid(ClaimedLetters, InStr(1, ClaimedLetters, Letter), 1) = "#"
Else
Me.Cells(GuessRow, i + 1).Interior.Color = RGB(120, 124, 126) ' Gray
End If
End If
Next i
' 4. Check for Win/Loss (Win check is done via color)
Dim isWin As Boolean
isWin = True
For i = 2 To 6
If Me.Cells(GuessRow, i).Interior.Color <> RGB(106, 170, 100) Then
isWin = False
Exit For
End If
Next i
If isWin Then
Me.Range("B2").Value = "YOU WIN!"
' FIX: Loss condition added for the final row (Row 8)
ElseIf GuessRow = 8 Then
Me.Range("B2").Value = "Better luck next time. The word was " & SecretWord
End If
' 5. LOCK THE CURRENT ROW and UNLOCK THE NEXT ROW for sequential play
Me.Range("B" & GuessRow & ":F" & GuessRow).Locked = True ' Lock the row just completed
' Only unlock the next row if the game isn't won and there are more rows
If Not isWin And GuessRow < 8 Then
Me.Range("B" & (GuessRow + 1) & ":F" & (GuessRow + 1)).Locked = False ' Unlock the next row
End If
End If
Me.Protect "YOUR_PASSWORD" ' Re-protect the sheet using the password you set
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
' If the sheet was already protected, this ensures it gets protected again even if the IF block above was skipped.
If Not Me.ProtectContents Then Me.Protect "YOUR_PASSWORD"
End Sub

Now, with the VBA window still open, press Ctrl+H to launch the Replace window. In the Find What field, type YOUR_PASSWORD, and in the Replace With field, type a password you’ll use later to secure your worksheet. Make a note of this! Then, click “Replace All,” and you’ll see the password be replaced four times.

The YOUR_PASSWORD string in a VBA code in Excel replaced with the word 'Wordle' in the Replace dialog.

Close the Replace window.

Because the first line of the code contains an event handler that automatically triggers when any cells are modified, you must temporarily disable it until you’ve finished setting up the spreadsheet. To do this, with the VBA window still open, click “View” on the ribbon and select “Immediate Window.”

The Immediate Window option in the View drop-down menu of Excel's VBA editor is selected.

Then, copy and paste the following into the Immediate Window, and press Enter:

Application.EnableEvents = False
Application.EnableEvents = False is typed into Excel's VBA Immediate Window.

Minimize the VBA window to return to the Wordle worksheet. Press Ctrl+S to save the file.

Don’t make any guesses on the game board just yet! We’ll test the worksheet’s functionality in Step 7.

Step 4: Limiting player inputs

Next, you need to control how the player enters their input. In other words, you want to force them to enter a single letter into each cell, rather than typing the whole word in one go.

This step could be integrated into the VBA code, but there are a few reasons why I prefer using data validation:

  • The player gets feedback on invalid entries before the input is accepted (the macro runs only after the cell value has changed).
  • Data validation is a native Excel feature that takes hardly any time to process (the macro must initialize, check the cell input, then clear the cell, taking more time and eating up more resources).
  • Using data validation is straightforward—one simple formula handles all the cells in the game board (a VBA macro would require additional complex code).

Select cells B3 to F8, and in the Data tab on the ribbon, click the “Data Validation” icon.

Some cells in Excel are selected, and the Data Validation button in the Data tab is selected.

Now, select “Custom” from the Allow drop-down menu, and copy the following into the Formula field:

=AND(LEN(B3)=1,ISERROR(VALUE(B3)))
A formula using AND, LEN, ISERROR, and VALUE is typed into the Formula field of Excel's Data Validation dialog.

Open the “Error Alert” tab, and select “Stop” in the Style drop-down menu. In the Title field, type Invalid letter. Then, in the Error Message field, type Enter only one letter per cell, and click “OK.”

The Error Alert area in Microsoft Excel's Data Validation dialog box, with the title 'Invalid Letter', and the error message 'Enter only one letter per cell'.

Press Ctrl+S to save the file.

A hand holding the Excel logo and another holding spreadsheet cells with green check marks and red error symbols, representing data validation in Excel.

Excel’s Custom Data Validation: A Trick You Didn’t Know You Needed

Create specific data entry rules for cells in your spreadsheet.

Step 5: Adding game instructions

This step adds visual quality to your game by telling the player how to play.

Copy the following formula, and paste it into cell B2:

=" Guess the 5-letter word. Type one letter per cell and use the Right Arrow key to navigate."

I deliberately added a space before the word “Guess” so that Excel’s autocomplete doesn’t trigger when the player types the letter “G” as the first letter of a guess.

Next, select cells B2 to F2, and click “Merge And Center” and “Wrap Text” in the Home tab.

Wrap Text and Merge And Center are applied to cells B2 to F2 in Excel.

Press Ctrl+S to save the file.

Step 6: Polishing and protecting the game

You’re nearly there, but there are a few more quick things to do before you can test the game and send it to your friends.

First, hide the secret word by right-clicking the row 1 heading and selecting “Hide.” This also pushes the game grid higher up the screen.

Row 1 in a Microsoft Excel worksheet is selected, and Hide is selected from the right-click menu.

Next, you need to make sure the player can only select the cells in the first row when they start playing (the VBA will handle sequential navigation once they’ve finished their first guess). Select cells B3 to F3, and press Ctrl+1 to open the Format Cells dialog box. Open the “Protection” tab, uncheck “Locked,” and click “OK.”

The Protection tab in Excel's Format Cells dialog box is opened, and Locked is unchecked.

All the other cells are locked by default when the game begins, so you can now protect the worksheet. In the Review tab, click “Protect Sheet.” Then, type the password you added to the code in Step 3, and make sure only the following options are checked:

  • Protect worksheet and contents of locked cells
  • Select unlocked cells
Select Unlocked Cells is checked and a password is entered in Microsoft Excel's Protect Sheet window.

Click “OK,” and confirm the password.

Next, protect the WordList worksheet, checking only “Protect worksheet and contents of locked cells.”

The Protect Sheet dialog in Excel, with Protect Worksheet And Contents Of Locked Cells checked.

Now, head back to Sheet1, and in the View tab, uncheck “Headings.”

Headings is unchecked in Excel's View tab.

Lastly, head back to the VBA window you minimized earlier, and in the Immediate Window, replace the word “False” with True, and press Enter. This kicks the code into action.

Application.EnableEvents = True is typed into Excel's VBA Immediate Window.

Save and close the entire VBA window, and press Ctrl+S to save the file.

Step 7: Making a test copy

At this point, you’re probably itching to test the game. However, don’t do this in the current version of the file! Instead, create a copy.

Close Excel, and locate the folder where you saved the macro-enabled workbook. Then, select the file and press Ctrl+C > Ctrl+V to duplicate it.

An Excel file called Wordle and a copy of the same file in a Windows 11 file explorer folder.

Now, open the copy, and click “Enable Content.”

The Enable Content button in the Macro security warning message in Microsoft Excel.

Experiment with your game board: type an invalid word, insert more than one letter into a cell, see what happens when you finish a row, use lowercase letters, repeat a word, and so on.

Step 8: Sending the game to your friends

The best part of creating a viral game is sharing it! Since the whole game is contained within a single Excel file, sharing is simple, but you must make sure you send a copy (rather than a sharing link) of the original workbook, such as through an email attachment—you don’t want everyone playing on the same version! Also, remember to tell the players they must click “Enable Content” when they open the workbook. Feel free to copy my screenshot above to make this clear.

A smartphone with a few word puzzle apps.

7 Word Games I Play After I Complete Wordle

Finished today’s Wordle? Try these other fun word games!

Step 9: Resetting the word and message

Because you made a test copy in Step 7, the grid in the master copy should be clear. So, when you want to create a new game the following day, you just need to reset the secret word. However, you must temporarily disable the macros to do this.

Open the original workbook, and click “Enable Content.” Then, in Sheet1, click “Unprotect Sheet” in the Review tab, type the password, and click “OK.”

Unprotect Sheet in Excel's Review tab is selected, and a password is typed into the resultant dialog.

Next, right-click the “Sheet1” tab and click “View Code.” Then, click “View” on the VBA window’s ribbon, select “Immediate Window,” and type the following and press Enter:

Application.EnableEvents = False
Application.EnableEvents = False is typed into Excel's VBA Immediate Window.

Minimize the VBA window to head back to the Wordle board, and check “Headings” in the View tab on the ribbon.

Headings is checked in the View tab on Microsoft Excel's ribbon.

Press Ctrl+A repeatedly until all the cells in the spreadsheet are selected, then right-click the row 2 heading, and click “Unhide.”

All cells in an Excel worksheet are selected, and the Unhide button in the right-click row heading menu is selected.

Now, type a new word into cell A1 using block caps, hide row 1, remove the headings, and reset the password via “Protect Sheet,” making sure only “Protect worksheet and contents of locked cells” and “Select unlocked cells” are still checked.

Go back to the Immediate Window, replace “False” with True, press Enter, and close the VBA window.

Application.EnableEvents = True is typed into Excel's VBA Immediate Window.

Press Ctrl+S to save the file, close Excel, and send the new game to your friends.


Creating a fully-housed Wordle board isn’t the only way I have fun with Microsoft Excel. For my friends who prefer more of a challenge, I use the program to create printable crossword puzzles, leveraging simple tools like precise cell formatting, color fill, and cell borders.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button