VBA & Macro Problems

Show an Automatic Message When Fail Is Selected in Excel

Elise WilliamsElise Williams Nov 14, 2026 869 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Open the worksheet code

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.

2
Add the event code

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

3
Save as a macro-enabled workbook

In Excel, select File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). If you reopen the trusted file, enable macros when prompted.

4
Test the reminder

Select Fail from a validation list in the specified range. Excel should display a Replace Now message box; dismiss it with OK.

Use a Worksheet Change Event to Show a Fail Reminder
Message box behavior: The reminder also appears if Fail is pasted or typed into a monitored cell. If several cells change at once, the code shows one message for that change.
Free Microsoft Office alternative

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.

Review and edit Pass or Fail spreadsheet lists in a familiar interfaceOpen and edit common Excel formats, including XLSX and XLSUse a free, lightweight office suite for everyday workbook tasks
microsoft office alternative - wps office

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.