Fix an Excel VBA Message Box That Displays False
Question details
Show the intended text in an Excel VBA message box instead of a Boolean value.

- 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.
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.
Pass the message text directly to MsgBox
Use this fix when the message box shows False instead of the intended completion text.
In Excel, open the Visual Basic Editor and select the module containing the affected macro.
Find the statement written like MsgBox sTemp = "text". Replace it with MsgBox "Refreshed Scoring Template and Formulas".
To display text stored in a variable instead, use two separate statements: sTemp = "Refreshed Scoring Template and Formulas" followed by MsgBox sTemp.
Run the procedure from the Visual Basic Editor or through Excel's Macros dialog and check the message.

List numerically named worksheets in the message
Use this approach when the completion message should include the names of worksheets whose names are numeric.
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.

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.




