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

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial


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:


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  • Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  • Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  • No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  • Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
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 · 1 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 · 1 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 · 1 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 · 10 months ago
          Hi,
          Sorry for replying so late. Please contact me at zxm@addin99.com.