VBA & Macro Problems

Show an Excel Pop-Up When Column C Contains X

Khadija KhanKhadija Khan Nov 18, 2026 870 views

Question details

Display a message when an Excel workbook opens if any cell in column C of Sheet1 contains X.

Show an Excel Pop-Up When Column C Contains X
Product
Microsoft Excel
Device & OS
not provided
Scenario
The workbook needs to check Sheet1 automatically each time it opens.
Observed behavior
A pop-up should appear at opening when a cell in column C has the value X.
Before you start

Confirm that the worksheet tab is named Sheet1 and that you can use the desktop version of Excel with VBA enabled. If the sheet has a different name, use that name in the code.

Solution 1Recommended

Use a Workbook_Open macro to search column C

Run a VBA search automatically when the workbook opens and show a message if an exact X is found.

The search matches the entire displayed cell value, so it finds X but not text such as XYZ. It is not case-sensitive, so it also finds lowercase x.

1
Save as a macro-enabled workbook

In Excel, select File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm).

2
Open the workbook module

Select Developer > Visual Basic. In the Project pane, find your workbook and double-click ThisWorkbook. If the Developer tab is hidden, enable it through File > Options > Customize Ribbon.

3
Add the open-event code

Paste this code into the ThisWorkbook module: Private Sub Workbook_Open() Dim ws As Worksheet Set ws = ThisWorkbook.Worksheets("Sheet1") If Not ws.Columns("C").Find(What:="X", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) Is Nothing Then MsgBox "X was found in column C of Sheet1.", vbInformation, "Value found" End If End Sub If a Workbook_Open procedure already exists, add the search code inside it instead of creating a second procedure with the same name.

4
Save and test

Save the workbook, close it, and reopen it in desktop Excel. If prompted and you trust the workbook, select Enable Content. A message appears if column C contains an exact X.

Use a Workbook_Open macro to search column C
Macros must be allowed: The open event cannot run if macros are disabled or blocked. Only enable macros in workbooks you trust.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar spreadsheet interface for a smooth move from Microsoft Office. It does not fix Excel's macro settings, and VBA support can vary by WPS version and platform.

Review and edit spreadsheet data in a familiar interfaceOpen and edit Microsoft Excel XLSX and XLS filesCheck worksheet values using spreadsheet search toolsUse a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the message not appear when I open the workbook?

Check that the file is saved as .xlsm, the code is in ThisWorkbook, and the worksheet is named Sheet1. Reopen it in desktop Excel and select Enable Content if prompted and you trust the file.

Will the macro find an X inside a longer word?

No. The Find setting LookAt:=xlWhole matches the entire cell value. Change it to LookAt:=xlPart if you want to find X within longer text.

Does the search distinguish uppercase X from lowercase x?

No. MatchCase:=False finds either case. Change it to MatchCase:=True to search only for uppercase X.

What if my worksheet is not named Sheet1?

In the ThisWorkbook code, replace Sheet1 in Worksheets("Sheet1") with the exact name shown on the worksheet tab.