Logical · The foundational conditional

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.

=IF(logical_test, value_if_true, [value_if_false])

Evaluates a condition. If TRUE, returns one value. If FALSE, returns another. The building block of conditional logic in Excel.

Category
Logical
Returns
One of two values
Available since
Excel 1.0 (all versions)

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

logical_test Required

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.

value_if_true Required

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 "".

value_if_false Optional

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

Example 1 · Basic pass/fail

Categorize a score as passed or failed

Test score in A2. Passing threshold is 60. Return "Pass" or "Fail".

=IF(A2>=60, "Pass", "Fail")
Result: "Pass" if A2 is 60 or higher, otherwise "Fail"

The classic two-outcome IF. Copy this pattern and change the values for any binary decision.

Example 2 · Prevent division by zero

Safe calculation with fallback

Calculate B2/C2 but avoid #DIV/0! errors when C2 is zero.

=IF(C2=0, 0, B2/C2)
Result: the division result, or 0 if the denominator 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.

Example 3 · Multiple conditions with AND

Combine conditions for compound rules

Mark an order as "Ready to ship" only if the payment is received AND the stock is available.

=IF(AND(D2="Paid", E2>0), "Ready to ship", "Hold")
Result: "Ready to ship" only if both conditions are true, otherwise "Hold"

Read our AND function guide for more on combining multiple conditions.

Example 4 · Nested IF for tiers

Grade a score across four brackets

Score in A2. Return grade based on brackets: 90+ = A, 80+ = B, 70+ = C, otherwise F.

=IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", "F")))
Result: the letter grade matching the score's bracket

Nested IF works but gets ugly fast. For 3+ tiers, consider IFS which handles multiple conditions cleanly.

Example 5 · Empty check with fallback

Handle blank cells gracefully

If a form field is blank, show "Please fill this in". Otherwise, echo the value.

=IF(A2="", "Please fill this in", A2)
Result: the friendly prompt if empty, otherwise the actual 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

#NAME?

Text values without quotes

You wrote =IF(A2=paid, "yes", "no") — Excel thinks "paid" is a named range that doesn't exist.

Fix: wrap text in quotes: =IF(A2="paid", "yes", "no")
#VALUE!

Text-based comparison on numbers

Comparing text and numbers can produce unexpected results. =IF(A2>"0", ...) compares string values, not numeric.

Fix: keep quotes off numeric comparisons — =IF(A2>0, "yes", "no")
FALSE

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.

Fix: always include value_if_false explicitly — =IF(A2>10, "big", "small") or =IF(A2>10, "big", "")
Wrong result

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.

Fix: order nested IFs from most restrictive to least: =IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", "F")))

For deeper error diagnosis, see our Formula Errors guide.

IF vs IFS vs SWITCH — when to use each

IF Use when: one condition, two outcomes. "Is this over 100? Yes or no?" The default for simple binary decisions.
Nested IF Use when: 2-3 tiers on older Excel. Beyond 3 tiers, switch to IFS. Difficult to maintain past 3 levels.
IFS Use when: multiple conditions with different outcomes. Grade brackets, tier assignments. Excel 2019+. Read our IFS guide.
SWITCH Use when: matching one value against a list of possibilities. Cleaner than IFS when the comparison is always the same variable. Excel 2019+.
IFERROR Use when: catching errors from other formulas. Better than IF+ISERROR for the common case. Read our IFERROR guide.
Lookup table Use when: 5+ tiers or complex mappings. Build a lookup table and use VLOOKUP/XLOOKUP against it instead of nesting IFs.

Version compatibility

Excel 365
✓ Full support
Excel 2021
✓ Full support
Excel 2019
✓ Full support
Excel 2016
✓ Full support
Excel Online
✓ Full support
Excel Mac
✓ Full support
Excel iPad
✓ Full support
Google Sheets
✓ Full support

Related functions

📥 Download the practice workbook

All 5 examples above in a working .xlsx file. Includes a nested IF exercise and IFS comparison sheet.

Workbook coming soon — check back after our team releases it.

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 →