Show an Automatic Message When Fail Is Selected in Excel
Question details
Display a Replace Now message automatically when a user selects Fail from a data-validation list.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains a Pass or Fail data-validation list, and a Fail selection should prompt the user to take action.
- Observed behavior
- The desired result is an immediate message whenever a monitored cell changes to Fail.
Identify the worksheet and cell range containing the Pass or Fail list. Use desktop Excel with macros available, and enable macros only for files you trust.
Use a Worksheet Change Event to Show a Fail Reminder
Use this VBA event to display an immediate pop-up when a monitored cell changes to Fail.
A data-validation input message normally appears when a cell is selected, not automatically after its value changes. A Worksheet_Change event can show a separate message box immediately.
Right-click the worksheet tab containing the validation list and select View Code. Paste the event code into that worksheet's code window, not a standard module.
Paste the following code, replacing B2:B100 with the cells that contain your validation list: Private Sub Worksheet_Change(ByVal Target As Range) Dim changedCells As Range Dim cell As Range Set changedCells = Intersect(Target, Me.Range("B2:B100")) If changedCells Is Nothing Then Exit Sub For Each cell In changedCells.Cells If Not IsError(cell.Value2) Then If LCase$(Trim$(CStr(cell.Value2))) = "fail" Then MsgBox "Replace Now", vbExclamation, "Validation reminder" Exit For End If End If Next cell End Sub
In Excel, select File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). If you reopen the trusted file, enable macros when prompted.
Select Fail from a validation list in the specified range. Excel should display a Replace Now message box; dismiss it with OK.

Work With Excel Spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday workbook tasks between suites. It does not fix Excel's VBA event behavior.

Frequently Asked Questions
Why doesn't an Excel input message appear immediately after I select Fail?
A data-validation input message is designed to appear when its cell is selected. For an immediate alert after the value changes, use a Worksheet_Change event with a message box.
Where should I put the Worksheet_Change code?
Right-click the tab of the worksheet containing the list, select View Code, and paste the event into that worksheet's code window. Change B2:B100 to the actual monitored range.
Why does the macro stop working after I save the workbook?
Save the file through File > Save As as an Excel Macro-Enabled Workbook (*.xlsm). When reopening a trusted file, enable macros if Excel prompts you.
Can I highlight Fail without using a macro?
Yes. Select the relevant cells and use Home > Conditional Formatting > Highlight Cells Rules > Text that Contains. Enter Fail and choose a format. This highlights the cell but does not show an automatic pop-up.




