How to Use IF With AND and OR in Excel
To use OR in an IF statement, write =IF(OR(condition1, condition2), value_if_true, value_if_false). The result is true when at least one condition is true. For AND, every condition must be true: =IF(AND(condition1, condition2), value_if_true, value_if_false). In both, the AND or OR closes right after its conditions, and the two results belong to the outer IF.
On this page▾
Start with plain IF
Microsoft's IF documentation gives the syntax as:
IF(logical_test, value_if_true, [value_if_false])
The first argument is the test, the second is what to return when the test is true, and the third (optional) is what to return when it is false. Microsoft's simple example is =IF(C2="Yes",1,2): return 1 if C2 says Yes, otherwise 2. Microsoft also notes that any text you want returned must be wrapped in quotes, with TRUE and FALSE as the only exception.
If you leave out the third argument and the test is false, Excel returns FALSE. For example, =IF(G12>=10000,"Yes") with 9,800 in G12 shows FALSE, which looks odd in a report. Give IF both answers.
How do AND, OR and NOT fit inside IF?
Microsoft's page describes the three combinations like this:
- AND: all conditions must be true.
=IF(AND(condition1, condition2), value_if_true, value_if_false) - OR: only one condition needs to be true.
=IF(OR(condition1, condition2), value_if_true, value_if_false) - NOT: reverses a single condition.
=IF(NOT(condition), value_if_true, value_if_false)
The key detail, which Microsoft points out, is where the parentheses close. The AND, OR, or NOT closes right after its conditions. The two result values belong to the outer IF, not to AND.
Microsoft's own examples return exactly what the page says when entered in Excel. With 25 in A2 and 75 in B2, =IF(AND(A2>0,B2<100),TRUE,FALSE) returns TRUE, because both conditions hold. With 25 in A4 and 75 in B4, =IF(OR(A4>0,B4<50),TRUE,FALSE) also returns TRUE, because OR only needs the first condition. And with 25 in A6, =IF(NOT(A6>50),TRUE,FALSE) returns TRUE, because 25 is not greater than 50.
AND and OR accept up to 255 conditions, according to Microsoft, but the page also warns that formulas with more than a few become hard to build, test and maintain. NOT takes only one.
A worked example: sales bonus rules
Here is a small team table:
| Rep (F) | Sales (G) | Deals (H) | Tier (I) | Status (J) |
|---|---|---|---|---|
| Lee | 12,500 | 5 | Standard | Open |
| Kim | 9,800 | 6 | VIP | Closed |
| Park | 21,000 | 2 | Standard | Open |
| Cho | 10,000 | 3 | VIP | Open |
Rule 1: Bonus if sales are at least 10,000 and deals are at least 4.
=IF(AND(G11>=10000,H11>=4),"Bonus","No")
Filled down for the four rows, this returns Bonus for Lee and No for everyone else. Kim has the deals but not the sales. Park and Cho have the sales but not the deals. Note that >= means "at least," so Cho's 10,000 counts as meeting the sales condition.
Rule 2: Priority if the tier is VIP or sales are at least 20,000.
=IF(OR(I11="VIP",G11>=20000),"Priority","Standard")
This returns Standard for Lee and Priority for Kim, Park and Cho. Kim and Cho qualify through the tier, Park through sales.
Rule 3: Follow up unless the status is Closed.
=IF(NOT(J11="Closed"),"Follow up","")
This returns "Follow up" for Lee, Park and Cho, and leaves Kim's cell empty. The pair of quotes with nothing between them is how you return a blank-looking result.
Combining AND with OR
Rules can nest. Suppose the bonus policy changes to: sales of at least 10,000, plus either four deals or VIP tier.
=IF(AND(G11>=10000,OR(H11>=4,I11="VIP")),"Bonus","No")
Read it from the inside out. The OR checks the "either" part. Its result becomes the second condition of AND. With this rule, Lee and Cho get Bonus, while Kim (sales too low) and Park (two deals, not VIP) do not.
Count the parentheses as you type: each function you open needs its own closing parenthesis before the final value arguments of the IF.
Using the conditions without IF
You do not always need IF. =AND(G11>=10000,H11>=4) on its own returns TRUE for Lee and FALSE for the others. Microsoft's page shows that AND, OR and NOT can be used this way in conditional formatting rules, where the formula only needs to produce TRUE or FALSE. In a normal cell, IF is what turns TRUE and FALSE into labels people can read.
Common problems
Microsoft's IF page lists two that come up often:
- #NAME? in the cell usually means a function name is misspelled.
- An unexpected 0 in the cell can mean a result argument was left empty. Check both results; zero can also be an intentional result.
Also check that text comparisons use quotes, as in I11="VIP". A comparison with a number, such as G11>=10000, does not.
Hiding the errors a formula can return is covered in IFERROR vs IFNA, Which Errors Should You Hide?.
Frequently asked questions
How do I use IF with both AND and OR? Nest one inside the other, for example =IF(AND(G11>=10000,OR(H11>=4,I11="VIP")),"Bonus","No").
How many conditions can AND and OR take? Up to 255, according to Microsoft, though a few is the practical limit for formulas you need to maintain.
Why do I get #NAME? Usually a misspelled function name. An unexpected 0 can indicate an empty result argument, but it can also be a legitimate result.
Sources
About this guide
Howlane operator · Checked against the official sources listed above. It is general information, not professional advice.
AboutEditorial standardsCorrectionsReport an error
Edit history
- Updated
- Updated
- Updated
- Updated
- Published