VBA If and / or statement

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
365
Hi, I would like to modify this code with the added And statement as shown below. Can someone help? Thanks

VBA Code:
If Range("AU20").Value = "ADD CONT SIDE" Or Range("AV20").Value = "ADD MOUNT TYPE" Then
        response = MsgBox("CONTROL SIDES OR MOUNT INFO IS MISSING - HIT YES TO CONTINUE OR NO TO ABORT", vbYesNo)
    If response = vbNo Then
    Exit Sub
    End If
    End If


Revise to:

If Range("B23").Value <> "SR" and Range("AU20").Value = "ADD CONT SIDE" Or Range("AV20").Value = "ADD MOUNT TYPE" Then
response = MsgBox("CONTROL SIDES OR MOUNT INFO IS MISSING - HIT YES TO CONTINUE OR NO TO ABORT", vbYesNo)
If response = vbNo Then
Exit Sub
End If
End If
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
If Range("23").Value <> "SR" And Range("AU20").Value = "ADD CONT SIDE" Or Range("AV20").Value = "ADD MOUNT TYPE" Then
response = MsgBox("CONTROL SIDES OR MOUNT INFO IS MISSING - HIT YES TO CONTINUE OR NO TO ABORT", vbYesNo)
If response = vbNo Then
Exit Sub
End If
End If
 
Upvote 0
If Range("23").Value <> "SR" And Range("AU20").Value = "ADD CONT SIDE" Or Range("AV20").Value = "ADD MOUNT TYPE" Then
response = MsgBox("CONTROL SIDES OR MOUNT INFO IS MISSING - HIT YES TO CONTINUE OR NO TO ABORT", vbYesNo)
If response = vbNo Then
Exit Sub
End If
End If
Thanks. I pretty much had and didn't know it.
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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