Sub topic 7
Combining Conditions with AND, OR, and NOT
This chapter assumes you can write a basic IF formula, use the comparison operators (=, <>, >, <, >=, <=), and copy a formula down a column. A single test is often not enough. You may need "both scores are passing" or "the customer is Gold or Platinum." AND, OR, and NOT let you build one logical test from several smaller ones.
How the three functions work
Each function returns TRUE or FALSE, which is exactly what the first argument of IF needs.
| Function | Returns TRUE when | Example |
|---|---|---|
| `AND(test1, test2, ...)` | every test is true | `AND(B2>=60,C2>=60)` |
| `OR(test1, test2, ...)` | at least one test is true | `OR(D2="Gold",D2="Platinum")` |
| `NOT(test)` | the test is false | `NOT(D2="Gold")` |
You place them inside IF as the logical test:
AND: every condition must hold
Suppose B2 and C2 hold two exam scores, and a student passes only if both are at least 60.
=IF(AND(B2>=60,C2>=60),"Pass","Fail")If B2 is 72 and C2 is 55, the second test is false. AND returns FALSE, so the formula returns "Fail".
Each test inside AND must be a complete test. Writing AND(B2,C2>=60) is a common slip. Excel treats B2 as a bare number, not as a comparison. Repeat the full test each time: B2>=60, C2>=60.
OR: any one condition is enough
Suppose D2 holds a customer tier. Both Gold and Platinum customers get priority handling.
=IF(OR(D2="Gold",D2="Platinum"),"Priority","Standard")A beginner often writes D2="Gold" or "Platinum". Excel does not read formulas like English. Each value needs its own full test inside OR.
NOT: reverse a test
NOT flips TRUE to FALSE and the reverse. It is useful when the condition you care about is easier to describe by what it is not.
=IF(NOT(D2="Gold"),"Standard","Gold member")In many cases the <> operator does the same job more simply: IF(D2<>"Gold","Standard","Gold member"). NOT earns its place when it wraps a whole AND or OR.
=IF(NOT(OR(D2="Gold",D2="Platinum")),"Standard","Priority")This returns "Standard" when D2 is neither Gold nor Platinum.
Mixing AND and OR
You can nest the functions inside each other. Suppose an order ships free when the total in B2 is at least 50, and the customer in D2 is either Gold or Platinum.
=IF(AND(B2>=50,OR(D2="Gold",D2="Platinum")),"Free shipping","Standard shipping")Read it from the inside out. The OR produces one TRUE or FALSE. The AND then combines that result with the total test.
Combining with threshold cells
You can mix these functions with the absolute references from the previous chapter. If F1 holds the passing mark, the formula stays readable and easy to change:
=IF(AND(B2>=$F$1,C2>=$F$1),"Pass","Fail")Change F1 once and every row updates.
Exercises
Exercise
Column B holds a sales total and column C holds a region. Write a formula for row 2 that returns "Bonus" when sales are at least 1000 and the region is "North", and "No bonus" otherwise.
Show answer
=IF(AND(B2>=1000,C2="North"),"Bonus","No bonus")
Exercise
What is wrong with this formula, and how do you fix it? =IF(OR(D2="Gold","Platinum"),"Priority","Standard")
Show answer
The second argument of OR, "Platinum", is not a test. It is a text value, which OR cannot evaluate as TRUE or FALSE. Write the full comparison: =IF(OR(D2="Gold",D2="Platinum"),"Priority","Standard").