VBA & Macro Problems

Fix an Excel VBA Message Box That Displays False

Muhammad TalhaMuhammad Talha Nov 18, 2026 870 views

Question details

Show the intended text in an Excel VBA message box instead of a Boolean value.

Fix an Excel VBA Message Box That Displays False
Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
A macro displays a completion message and may include the names of worksheets with numeric names.
Observed behavior
A statement such as MsgBox sTemp = "text" evaluates a comparison and displays False when the values do not match.
Before you start

Open the workbook containing the macro and locate the procedure in the Visual Basic Editor. Identify the MsgBox statement and any worksheet loop that builds the message.

Solution 1Recommended

Pass the message text directly to MsgBox

Use this fix when the message box shows False instead of the intended completion text.

1
Open the macro

In Excel, open the Visual Basic Editor and select the module containing the affected macro.

2
Replace the comparison

Find the statement written like MsgBox sTemp = "text". Replace it with MsgBox "Refreshed Scoring Template and Formulas".

3
Display a variable if needed

To display text stored in a variable instead, use two separate statements: sTemp = "Refreshed Scoring Template and Formulas" followed by MsgBox sTemp.

4
Run the macro

Run the procedure from the Visual Basic Editor or through Excel's Macros dialog and check the message.

Pass the message text directly to MsgBox
Why False appears: In MsgBox sTemp = "text", VBA evaluates whether sTemp equals the text and passes the resulting True or False value to MsgBox.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Excel files. It supports a smooth move for everyday spreadsheet work, though VBA macro support and behavior can vary and should be tested separately.

Open and edit common Excel XLSX and XLS filesUse familiar spreadsheet tools for everyday workbook tasksReview worksheet names and workbook content in WPS SpreadsheetMove existing spreadsheets without learning an entirely new interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does MsgBox sTemp = "text" display False?

VBA treats sTemp = "text" as a comparison in that statement. If the values differ, MsgBox receives and displays False. Use MsgBox sTemp or pass the text directly instead.

How do I add worksheet names on separate lines?

Inside the worksheet loop, append each name with sTemp = sTemp & vbCrLf & WKS.Name. After the loop, concatenate sTemp with the message heading in MsgBox.

How can I include only sheets with numeric names?

In the worksheet loop, wrap the append or processing code in If IsNumeric(WKS.Name) Then and End If. This checks the worksheet name, not the values in its cells.

Where can I edit the VBA message box code?

Open the workbook in Excel, open the Visual Basic Editor, and select the module containing the macro. Edit the MsgBox statement in that procedure, then run it to check the result.

Will the worksheet list show anything if no names are numeric?

If sTemp starts empty and no worksheet names pass IsNumeric, the list remains empty. A message that combines a heading with sTemp will show only the heading.