Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to pop up message box if cell value equals “X” in Excel?

Popping up message box helps a lot while finding certain content in specified range. For example, you are finding cell value which equals 50 in a range A1:C7, and you need a message box popping up to tell you whether the cell value exist or not. The following two methods can help you.

Pop up message box if cell value equals “X” with VBA code

Easily pop up message box if cell value equals “X” with Kutools for Excel


Pop up message box if cell value equals "X" in Excel

Click Kutools > Select > Select Specific Cells. The Kutools for Excel's Select Specific Cells utility helps you easily find and select cell which contains or equals a certain value in Excel and pop up a message box.. See below screenshot:

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Read More      Free Download Now

doc message box if cell value 7

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

Pop up message box if cell value equals “X” with VBA code


The following VBA code can help to create a pop up message box when the certain value exists in specified range. Please do as follows.

1. In the worksheet you need to check values in specified range, right click the tab name in the sheet tab bar, and then click View Code from the right-clicking menu. See screenshot:

doc message box if cell value 1

2. In the Microsoft Visual Basic for Applications window, copy and paste the following VBA code into the Code window.

VBA code: pop up message box if cell value equals “X”

Private Sub Worksheet_Change(ByVal Target As Range)
'Update: 2017/7/25
    Dim xCell As Range, Rg As Range
    On Error Resume Next
    Set Rg = Application.Intersect(Target, Range("A1:C7"))
    If Not Rg Is Nothing Then
        For Each xCell In Rg
            If xCell.Value = "50" Then
                MsgBox "guest entered into cell " & xCell.Address, vbInformation, "Kutools for Excel"
                Exit Sub
            End If
        Next
    End If
End Sub
Private Sub Worksheet_selectionChange(ByVal Target As Range)
    Dim xCell As Range, Rg As Range
    On Error Resume Next
    Set Rg = Application.Intersect(Target, Range("A1:C7"))
    If Not Rg Is Nothing Then
        For Each xCell In Rg
            If xCell.Value = "50" Then
                MsgBox "guest entered into cell " & xCell.Address, vbInformation, "Kutools for Excel"
                Exit Sub
            End If
        Next
    End If
End Sub

3. Press Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window and go back to the worksheet.

From now on, when cell values are changed in range A1:C7 and there is cell value equals “50”, you will get a message box as below screenshot shown.

Besides, you can just select the range to pop up the message box if the cell value exists.

doc message box if cell value 1

Notes:

1. If the cell value does not meet the criteria, the message box won’t pop up.

2. In the above code, you can change the cell reference and value to your need.

3. It only can display one matching cell reference when there are multiple results.


Pop up message box if cell value equals “X” with Kutools for Excel

The Select Specific Cells utility of Kutools for Excel can also help you to solve this problem. Please do as follows.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

1. Select the range you want to find if cell value existing in, then click Kutools > Select > Select Specific Cells. See screenshot:

2. In the Select Specific Cells dialog box, select the Cell option in the Selection type section, then select Equals in the first Specific type drop-down list and type the cell value in the next text box, and finally click the OK button.

doc message box if cell value 1

If the cell value exists in specified range, you will get the following message box, click the OK button, the cell will be selected.

doc message box if cell value 1

Otherwise, you will get the message box as below screenshot shown.

doc message box if cell value 1


Easily pop up message box if cell value equals “X” with Kutools for Excel

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Related articles:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    AWhite · 1 years ago
    Is there a way to update for 2 values in the same range? ex "50" or "100" ?
    • To post as a guest, your comment is unpublished.
      AWhite · 1 years ago
      I also tried duplicating this code, and changing to a different range where my data is repeated, but it appears the "Worksheet - Change" function can only be used once. Is this true?
  • To post as a guest, your comment is unpublished.
    Tango · 2 years ago
    This script works fine when the cell was enter manually. But when I try to copy the whole line from the other line and paste it to the new line, the pop up window will still come up even the cell on the new line didn't contain the key word.

    Any way to get rid of it?
    Please advice. Thanks
    • To post as a guest, your comment is unpublished.
      Linda · 2 years ago
      Dear TANGO,
      Thank you for your comment! We have updated the VBA script to get rid of the problem you mentioned above. Hope the new code can ease your work.
      If you have any problem, please do hesitate to contact us!
      Thanks again for your comment!
      • To post as a guest, your comment is unpublished.
        cassidy joram · 2 years ago
        please need your help give me your email address Linda mine is mineralsuganda256@gmail.com
        • To post as a guest, your comment is unpublished.
          crystal · 1 years ago
          Hi,
          Sorry for replying so late. Please contact me at zxm@addin99.com.