IF
The most-used logical function in Excel. Test a condition, return one value if true, another if false. Simple to start, powerful when combined — the foundation of every conditional formula in every workbook.
Evaluates a condition. If TRUE, returns one value. If FALSE, returns another. The building block of conditional logic in Excel.
What IF does
IF is the most fundamental decision-making function in Excel. Every Excel user learns it early and never stops using it. The pattern is simple: "if this condition is true, return X; otherwise return Y". That single pattern, applied millions of times a day across the world's workbooks, drives conditional formatting, categorization, error handling, data validation, and countless business rules.
The condition can be any comparison that Excel can evaluate as TRUE or FALSE — A1>100, B2="paid", ISBLANK(C3), or complex combinations using AND, OR, and NOT. The "true" and "false" branches can be numbers, text, dates, other formulas, or even more IF statements nested inside.
Syntax breakdown
The condition to evaluate. Anything that returns TRUE or FALSE. Common patterns: A1>100, B2="paid", C3<>"", ISBLANK(D4), AND(x>0, y<100), or the result of any function that returns a boolean.
What to return when the condition is TRUE. Can be a number, text (in quotes), date, cell reference, formula, or nested IF. Text must be wrapped in quotes: "Approved". Empty string is "".
What to return when the condition is FALSE. If omitted, IF returns FALSE (the literal word). Best practice is always to specify this argument explicitly, even if it's just "" or 0.
5 real-world examples
Categorize a score as passed or failed
Test score in A2. Passing threshold is 60. Return "Pass" or "Fail".
The classic two-outcome IF. Copy this pattern and change the values for any binary decision.
Safe calculation with fallback
Calculate B2/C2 but avoid #DIV/0! errors when C2 is zero.
Defensive coding for reports. You could also wrap in IFERROR, but IF gives you explicit control over exactly which condition triggers the fallback.
Combine conditions for compound rules
Mark an order as "Ready to ship" only if the payment is received AND the stock is available.
Read our AND function guide for more on combining multiple conditions.
Grade a score across four brackets
Score in A2. Return grade based on brackets: 90+ = A, 80+ = B, 70+ = C, otherwise F.
Nested IF works but gets ugly fast. For 3+ tiers, consider IFS which handles multiple conditions cleanly.
Handle blank cells gracefully
If a form field is blank, show "Please fill this in". Otherwise, echo the value.
Note the difference between ="" and ISBLANK(). Empty-string check matches cells that either are truly empty OR contain formulas returning empty strings.
Common errors and how to fix them
Text values without quotes
You wrote =IF(A2=paid, "yes", "no") — Excel thinks "paid" is a named range that doesn't exist.
Text-based comparison on numbers
Comparing text and numbers can produce unexpected results. =IF(A2>"0", ...) compares string values, not numeric.
Formula returns the word "FALSE" instead of a value
You wrote =IF(A2>10, "big") and omitted the value_if_false argument. Excel returns the literal word FALSE when the condition is false.
Nested IF returns unexpected values
You wrote =IF(A2>70, "C", IF(A2>80, "B", "F")) — but this always returns "C" for any score above 70, because the outer IF is evaluated first.
For deeper error diagnosis, see our Formula Errors guide.
IF vs IFS vs SWITCH — when to use each
Version compatibility
Related functions
📥 Download the practice workbook
All 5 examples above in a working .xlsx file. Includes a nested IF exercise and IFS comparison sheet.
Frequently asked questions
How many IFs can I nest inside each other?
Excel allows up to 64 nested IFs, but nobody should nest more than 3. Past 3, use IFS (multiple conditions), SWITCH (matching to a list), or a lookup table with VLOOKUP/XLOOKUP. Nested IFs beyond 3 become nearly impossible to read or debug.
What's the difference between IF blank and IF empty string?
=IF(A1="", ...) matches cells that are truly blank OR contain empty strings from formulas. =IF(ISBLANK(A1), ...) only matches truly empty cells — formulas returning "" don't count. Use ISBLANK when only genuine blanks should trigger the branch.
Can IF return different data types in the true and false branches?
Yes. =IF(A1>0, "positive", A1) returns text if positive, or a number otherwise. But downstream formulas may struggle with mixed types — better practice is consistent types.
How do I write IF that checks multiple conditions?
Use AND for "all must be true", OR for "any must be true". Example: =IF(AND(A1>0, B1<100), "in range", "out"). Or use IFS for multiple different outcomes based on multiple conditions.
Does IF slow down big workbooks?
Rarely. IF is highly optimized. What slows workbooks is thousands of IFs each doing expensive calculations (VLOOKUPs, array operations) — not IF itself. If performance matters, replace complex nested IFs with a lookup table.
Can I write IF without value_if_false?
You can, but you shouldn't. If omitted, IF returns the literal word FALSE when the condition is false. This is almost never what you want in a report. Always include value_if_false explicitly — even if it's just "" or 0.
How do I check "not equal" in an IF condition?
Use the <> operator. Example: =IF(A1<>"paid", "chase payment", "done"). Alternative: =IF(NOT(A1="paid"), ...) — both work, but <> is cleaner.
Nested IF logic, written for you.
Describe your logic — "if score is 90+ show A, 80+ show B, 70+ show C, otherwise F" — and get the exact nested IF or IFS formula.
Get the Add-in →