conditional pop up message

rubinda

New Member
Joined
Jun 26, 2018
Messages
36
I have a file and am looking in column E and G. If Column E="Bob's" and column G="1234", I'd like a message to pop up stating "abc". How do I write this. I have the code below, but that only looks at individual columns.

Sub Bob's()
If Range("E3:E30").Value = "Bob's" Then MsgBox "If this Bob's order is for a 1234, 5678 or 9101, ensure the appropriate dish setting."
If Range("G3:G30").Value = "1234" Then MsgBox "If this 1234 order is for Bob's, ensure appropriate dish setting."
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
try this,

Code:
Sub do_it()
For Each mycell In Range("E3:E30")
If mycell.Value = "Bob's" And Cells(mycell.Row, "G") = 1234 Then MsgBox "abc"
Next
End Sub

hth,
Ross
 
Last edited:
Upvote 0
You could use Validation to do this.
Select E1 and set validation to the custom formula =AND($E1="Bob's",$G1="1234")
Set the Error type to Information and the Error message to abc
 
Upvote 0
Thank you. What if I want to implement and if/or statement. If G3:G30 is = 1234, 5678 or 9101. How would I write that?
 
Upvote 0
try this

Code:
Sub do_it()
For Each mycell In Range("E3:E30")
r = mycell.Row
If mycell.Value = "Bob's" And (Cells(r, "G") = 1234 Or Cells(r, "G") = 5678 Or Cells(r, "G") = 9101) Then MsgBox '"abc"
Next
End Sub
 
Upvote 0
You are awesome! Last question and I am done with this file...

If I have a row, and my cell in column E="Bob's" and column G= 1234, 5678 or 9101, I'd like to change the text to red. Can you please assist?
 
Upvote 0
Code:
Sub do_it()
For Each mycell In Range("E3:E30")
r = mycell.Row
Rows(r).Font.ColorIndex = xlAutomatic
If mycell.Value = "Bob's" And (Cells(r, "G") = 1234 Or Cells(r, "G") = 5678 Or Cells(r, "G") = 9101) Then
    MsgBox "abc"
    Rows(r).Font.Color = -16776961
End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,370
Members
449,080
Latest member
Armadillos

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