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.
In this guide
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 |
Comparison operators: what to type
| Type | Means |
|---|---|
| = | is equal to |
| > | greater than |
| < | less than |
| >= | greater than or equal to: first >, then = |
| <= | less than or equal to: first <, then = |
| <> | not equal to: first <, then > |
Always two separate keys, never a special symbol.
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.
AND, OR & NOT practice: try it yourself
Reading is one thing, typing it is another. Build the formula below step by step: the tips tell you what to type next, and you can click or drag across cells to add them, just like in Excel.
Task: Check in D2 if the customer is 18 or older AND has agreed to the terms: =AND(B2>=18,C2="Yes")
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")).
In practice: free shipping and a member discount
A web shop gives free shipping when the order is at least 50 or the customer is a member. Members also get 10% off, but only on orders of 100 or more: that is an and.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Order | Amount | Member | Shipping | Discount |
| 2 | 1001 | 62 | No | Free | 0 |
| 3 | 1002 | 35 | Yes | Free | 0 |
| 4 | 1003 | 28 | No | Paid | 0 |
| 5 | 1004 | 120 | Yes | Free | 12 |
- D2:
=IF(OR(B2>=50, C2="Yes"), "Free", "Paid") - E2:
=IF(AND(B2>=100, C2="Yes"), B2*0.1, 0)
OR is enough for shipping: one of the two conditions has to be true. Only order 1003 pays. The discount needs AND: both conditions at once, so only order 1004 gets 12 off.
Keep learning
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.