Excel IF function
Excel IF then returns one value when a condition is true and another when false (IF else then). For “if this and that then …”, nest AND inside IF; use OR for any-match tests. Chain multiple IF statements (nested IF) or IFS when you need more than two outcomes.
IF statement syntax & arguments
The IF function is the foundational building block for spreadsheet decision logic. It returns one value if true, and another if false.
Any value or expression that evaluates to TRUE or FALSE (e.g. A2 >= 90, B2 = "Pending", or C2 > AVERAGE(C$2:C$10)).
The value to return when logical_test is TRUE. Can be double-quoted text (e.g. "Pass"), a number, a cell reference, or another calculation.
The value to return when logical_test is FALSE. If omitted, returns FALSE. Often chained with another nested IF for tiered grading.
Interview classic: letter-grade ladder
Evaluate thresholds strictly top-down (90 first, then 80, then 70). Once a condition matches, subsequent conditions are skipped.
How to write IF then / IF else then in Excel
- Start with the condition (logical_test) — Decide what to test: A2>=90 for a grade line, B2="Done" for a status match. The test must evaluate to TRUE or FALSE.
- Add the IF then and IF else then outcomes — value_if_true is the IF then result; value_if_false is the IF else then result. Wrap text values in double quotes.
- Chain multiple IF statements or switch to IFS — One IF handles two outcomes. For more thresholds, nest the next IF inside value_if_false (multiple IF statements) — or use the IFS function in modern Excel.
Excel IF AND / IF OR statements
The IF condition holds a single logical test. Nest AND or OR inside it to check several cells or thresholds at once. Spoken aloud, “if this and that then …” is exactly IF AND:
IF AND: every condition must be TRUE — both scores need to reach 60 before the then result (Pass) is returned.
IF OR statement: any single TRUE is enough — one score of 90 or higher passes.
IF cell contains text & IF not blank
IF has no built-in "contains" test. The classic pattern searches for the text, then converts the result to TRUE/FALSE with ISNUMBER:
SEARCH locates "urgent" inside A2 (case-insensitive) and returns a position number — or an error when missing; ISNUMBER turns that into TRUE/FALSE for IF. Use FIND for a case-sensitive match.
IF not blank: <>"" means "not equal to empty". To test for blank cells directly, use ISBLANK(A2).
Multiple IF statements: nested IF vs IFS
Nested IF (multiple IF statements)
Multiple IF statements nested inside each other work in every Excel version, Sheets, and interview assessments. Read top-to-bottom from the highest threshold.
IFS
Cleaner for many branches in modern Excel & Sheets: =IFS(A2>=90,"A", A2>=80,"B", A2>=70,"C", TRUE,"D"), avoiding closing parenthesis piles.
Common mistakes & gotchas
- Order matters — Threshold order matters: If you test A2>=70 first, a score of 95 will immediately match C. Always check highest thresholds first.
- Text quotes — Text return values must have quotes: "A", not bare A. Without quotes, Excel assumes it is a named range and triggers #NAME? error.
- Blank cells — Blank cells vs zero: Excel may treat blank cells as zero in certain mathematical comparisons. Use ISBLANK if empty cells need separate handling.
Related practice problems
Practice combining IF statements, lookups, and math formulas in realistic, bite-sized challenges.
FAQ
What is the IF formula syntax?
Use =IF(logical_test, value_if_true, value_if_false). For example =IF(A2>=60, "Pass", "Fail") returns Pass when A2 is at least 60, otherwise Fail.
How do I write an Excel IF then / IF else then formula?
Start with the condition, then the two outcomes: =IF(A2>=90, "A", "B"). value_if_true is the IF then result; value_if_false is the IF else then result. For more than two results, nest the next IF inside value_if_false, or use the IFS function in modern Excel and Google Sheets.
How do I use Excel IF AND and an IF OR statement?
Nest them in the condition. “If this and that then …” maps to =IF(AND(A2>=60, B2>=60), "Pass", "Fail") — both tests must pass. An IF OR statement uses OR instead: =IF(OR(A2>=90, B2>=90), "Pass", "Retry") passes when any single test is TRUE.
How do I write multiple IF statements in Excel?
Nest each next IF inside value_if_false — e.g. =IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","D"))). That pattern of multiple IF statements works in every Excel version. In modern Excel and Google Sheets, IFS is a cleaner alternative for many branches.
How do I check if a cell contains specific text with IF?
Combine ISNUMBER with SEARCH: =IF(ISNUMBER(SEARCH("urgent", A2)), "Priority", "Normal"). SEARCH is case-insensitive; use FIND for a case-sensitive match.
How do I write IF not blank in Excel?
Compare against an empty string: =IF(A2<>"", "Filled", "Empty"). To test for blank cells directly, use =IF(ISBLANK(A2), "Blank", "Has value").
What's the difference between IF, COUNTIF, and SUMIF?
IF returns one of two values based on a condition; COUNTIF counts cells matching a condition; SUMIF sums values matching a condition. They often work together: COUNTIF/SUMIF for aggregation, IF for per-row decisions.
When should I use nested IF vs IFS?
Nested IF (multiple IF statements) works everywhere. IFS is cleaner for many branches in modern Excel and Google Sheets.
Why does my nested IF return the wrong grade?
Order matters. Put the highest threshold first so earlier true conditions win.