Excel Guide
IF, AND & OR Formulas in Excel, From Basic to Nested
An IF and formula in Excel returns one value if a condition is true and another if it is false: =IF(condition, value_if_true, value_if_false). For example, =IF(A2>=60, "Pass", "Fail") marks a score as Pass only when it is 60 or more. This guide shows that pattern, then how to combine conditions with AND and OR, nest IFs for multiple outcomes, and when to use IFS instead — with 10 practice problems for each pattern. Practise it: Basic IF — 10 Excel practice problems.
The basic IF pattern
Every IF formula has the same three parts: a condition, what to return if it's true, and what to return if it's false.
That single pattern covers most of what you'll need: pass/fail thresholds, flagging over-budget rows, labeling categories.
IF with AND / OR: checking more than one condition
When a decision depends on more than one thing, wrap your conditions in AND (all must be true) or OR (at least one must be true), and use that as the IF's condition:
Three patterns cover most real cases:
- Between two numbers is an AND with a lower and an upper limit:
=IF(AND(A2>=2, A2<=8), "OK", "Out of range") - One of several values is an OR of text tests:
=IF(OR(A2="Sat", A2="Sun"), "Weekend", "Weekday") - "This, or both of these" is AND nested inside OR:
=IF(OR(A2>=700, AND(A2>=650, B2>=80000)), "Eligible", "Not eligible")
AND and OR accept as many conditions as you need, separated by commas, and text comparisons ignore capital letters ("yes" matches "Yes").
=IF(A2>=50 AND B2>=50, ...). Excel doesn't read that; AND has to be a function wrapped around the conditions: AND(A2>=50, B2>=50). Likewise =IF(2<=A2<=8, ...) doesn't test "between"; split it into two conditions inside AND.Nested IF: multiple outcomes
For more than two possible outcomes, you can nest one IF inside another:
This works, but readability drops fast past two or three levels of nesting. That's usually the sign to reach for IFS instead, which lists condition/result pairs without the nested parentheses:
The final TRUE, "F" pair acts as a catch-all default, similar to the innermost "else" in a nested IF.
IF(A2>=70, "C", IF(A2>=90, "A", ...)) will never return "A", because anything ≥90 already satisfies ≥70 and returns early. Always check from the highest threshold down (or the lowest up), not in random order.Try it yourself
Practice IF, AND, OR, and IFS with real interactive exercises and instant feedback.
Start practicing conditional formulas →