Combining If with multiple And/Or

K0D54

New Member
Joined
Aug 28, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello. I wanted to know if it's possible to combine an if statement with multiple and functions as well as or. I am trying to do something like this:

VBA Code:
If (UCase(Cells(i, "G").Value) <> "" And (UCase(Cells(i, "D").Value) = "PIZZA") Or (UCase(Cells(i, "G").Value) <> "" And (UCase(Cells(i, "D").Value) = "HAMBURGERS") Then

However, I am getting a compile error saying it is expected a ). I am unsure if what I am trying to do is possible or if I am just entering the information incorrectly. Any help would be much appreciated. Thank you.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
It sure is possible.
You have an error because you have 12 left parends "(" and 10 right ones ")".
The numbers must match exactly to have a valid formula.

Where you put them will also affect the groupings and how they work, i.e.
(A and B) or C
is not the same as:
A and (B or C)
 
Upvote 0
Solution
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
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