Sub topic 2
Comparing Text, Thresholds, and Multiple Conditions in Excel
Assume you can enter formulas, use cell references such as A2, and copy formulas down with the fill handle. This chapter uses those skills to compare text, fix a reference to a threshold cell, and combine conditions.
Comparing text: quotes and case
Text in a logical test must be enclosed in double quotation marks. Excel compares text without distinguishing uppercase from lowercase.
=IF(A2="Yes","Approved","Pending")If A2 contains Yes, yes, or YES, the result is Approved. Without quotation marks, Excel treats Yes as a name or reference instead of text.
Use <> to test whether text is different:
=IF(B2<>"Complete","Follow up","Done")| Operator | Meaning | Example |
|---|---|---|
| `=` | Equal to | `A2="Yes"` |
| `<>` | Not equal to | `B2<>"Complete"` |
Extra spaces are different characters. If a value may contain accidental spaces, use TRIM:
=IF(TRIM(A2)="Yes","Approved","Pending")Using a threshold cell with absolute references
An absolute reference keeps a row or column fixed when you copy a formula. Suppose F1 contains the target score. Use $F$1 so every row compares with that same cell:
=IF(B2>=$F$1,"Target met","Below target")B2 changes to B3, B4, and so on when copied down. $F$1 does not change.
Combining conditions with AND, OR, and NOT
AND requires every condition to be true. OR requires at least one. NOT reverses a result.
=IF(AND(B2>=60,C2>=60),"Pass","Fail")
=IF(OR(D2="Gold",D2="Platinum"),"Priority","Standard")
=IF(NOT(E2="Closed"),"Open","Closed")Place the combined test as the first argument of IF. Check that operators and quoted text match the intended rule.
Exercise
Write a formula that returns "Ready" only when A2 contains "Yes" and B2 is at least 10.
Show answer
=IF(AND(A2="Yes",B2>=10),"Ready","Not ready")