Home › Excel functions › AND, OR & NOT
AND, OR and NOT in Excel: Combine Conditions
AND, OR and NOT combine conditions into a single TRUE or FALSE. On their own they're rarely the final answer, but inside IF, filters and conditional formatting they're essential.
Syntax
| Function | Syntax | Returns TRUE when |
|---|---|---|
| AND | =AND(logical1, [logical2], …) | All conditions are true |
| OR | =OR(logical1, [logical2], …) | At least one condition is true |
| NOT | =NOT(logical) | The condition is false |
Example
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Student | Score | Assignment | AND | OR |
| 2 | Anna | 72 | Yes | TRUE | TRUE |
| 3 | Ben | 55 | Yes | FALSE | TRUE |
| 4 | Chris | 90 | No | FALSE | TRUE |
| 5 | Dana | 41 | No | FALSE | FALSE |
- Column D:
=AND(B2>=60, C2="Yes"). Only Anna meets both conditions. - Column E:
=OR(B2>=60, C2="Yes"). Everyone except Dana meets at least one.
Inside IF
Put AND or OR in the first argument of IF to return text instead of TRUE/FALSE:
=IF(AND(B2>=60, C2="Yes"), "Pass", "Fail") =IF(OR(B2="VIP", C2>1000), "Free shipping", "")A range check: is a value between 10 and 20? =AND(A2>=10, A2<=20). Note that Excel doesn't understand 10<=A2<=20; you always need AND.
NOT
NOT reverses a result. It's most useful with functions that return TRUE/FALSE:
=NOT(ISBLANK(A2)): TRUE when A2 is filled in.=IF(NOT(ISNUMBER(SEARCH("test", A2))), "Real order", "Test")
Often <> is simpler: =A2<>"Done" instead of =NOT(A2="Done").
In conditional formatting and FILTER
- Conditional formatting rule:
=AND($D2<TODAY(), $E2<>"Done")highlights overdue open tasks. - FILTER doesn't accept AND/OR on ranges; use
*for AND and+for OR instead:=FILTER(A2:C10, (B2:B10>=60)*(C2:C10="Yes")).
Frequently asked questions
How many conditions can AND and OR take?
Up to 255 conditions each.
Why does AND return #VALUE!?
None of the arguments produce TRUE or FALSE, for example when you refer to cells with text. Make sure each argument is a comparison.
What is XOR?
XOR ("exclusive or") returns TRUE when an odd number of conditions is true; with two conditions, when exactly one of them is true.