If a cell contains certain text

trevolly

Board Regular
Joined
Aug 22, 2021
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have a worksheet and I'd like to have a message box appear if a certain value (in this case text "Block 38S") is in the cell C12, which will be selected from a drop down menu within the cell C12.

The vba I have written for this works but I've discovered that if the cell C12 contains the value "Block 38S" then every time you select any other drop down list on the worksheet (in any other cell) then the message box pops up again.

Is there any way the vba can be written so the message box only appears for the cell C12?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Worksheets("Form").Range("C16").Value = "Block 38S" Then
MsgBox ("Please check if there any works planned on the Northern Runway")
Else
Exit Sub

Thank you all

End If
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
If you only want it to run when the value in C12 is updated, then change it like this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Intersect(Worksheets("Form").Range("C16"), Target) Is Nothing Then Exit Sub

If Worksheets("Form").Range("C16").Value = "Block 38S" Then
    MsgBox ("Please check if there any works planned on the Northern Runway")
End If

End Sub
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,097
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top