Excel IF Formula: How to Write One, With Examples (2026 Guide)

IF is the formula that lets a spreadsheet make a decision: if this is true, show that; otherwise, show something else. Pass or fail, paid or overdue, discount or no discount — most of the "thinking" in a spreadsheet is an IF formula somewhere. Here is the syntax once, then five examples that cover nearly every IF you will ever write.

The syntax, in plain English

=IF(test, value_if_true, value_if_false)

All three parts matter. Leave out the third one and Excel shows FALSE when the test fails, which is almost never what you want.

Example 1: Pass or fail

Column B holds exam scores. Mark each one:

=IF(B2>=60,"Pass","Fail")

Text results go in double quotes. Numbers do not: =IF(B2>100,B2*0.1,0) returns a 10% discount on orders over 100, and 0 otherwise.

Example 2: Grades with nested IF

Turn a score into a letter grade:

=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F")))

Read it as a chain: 90 or above is an A; if not, 80 or above is a B; if not, 70 or above is a C; otherwise F. Each IF sits inside the previous one's "false" slot. It works, but three levels deep is where most people start losing track of the brackets — which is why IFS exists.

Example 3: The same grades, with IFS

=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"F")

IFS lists each condition and its result as a flat pair, no nesting. The last pair, TRUE,"F", is the catch-all — TRUE is always true, so anything that fell through the earlier tests gets an F. IFS needs Excel 2019 or Microsoft 365; nested IF works in every version, including Google Sheets.

Example 4: Two conditions with AND and OR

Flag orders that are both large and unpaid:

=IF(AND(B2>500,C2="Unpaid"),"Chase","OK")

AND needs every condition true; OR needs just one: =IF(OR(B2="Overdue",C2<0),"Review","OK"). You can nest AND and OR inside each other for more complex rules, but if the logic needs a paragraph to explain, it is usually better as a lookup table or a helper column.

Example 5: Hide errors with IFERROR

Lookups that find nothing show #N/A. Wrap the lookup so the report stays clean:

=IFERROR(VLOOKUP("ABC123",A2:D100,3,FALSE),"Not found")

IFERROR is not an IF, but it is the formula people reach for next: if the first argument errors, show the second argument instead. (XLOOKUP has this built in — see our VLOOKUP vs XLOOKUP guide.)

The mistakes that break IF

FAQ

Can an IF formula return a number instead of text?

Yes — the value-if-true and value-if-false can be numbers, cell references, or other formulas. For example =IF(B2>100,B2*0.1,0) returns a 10% discount when the order is over 100, and 0 otherwise.

What is the difference between nested IF and IFS?

They do the same job, but IFS lists each condition and result as a flat pair, so it is much easier to read and edit than IFs nested inside each other. IFS needs Excel 2019 or Microsoft 365; nested IF works in every version.

Why does my IF formula return FALSE instead of my value?

You left out the value-if-false. =IF(B2>100,"Big") with no third argument returns FALSE when the test fails. Always write all three parts: test, value if true, value if false.

Describe it — get the formula

Type what you want in plain English and get the IF, IFS, or any other formula, explained. Free: 5 formulas a day, no account. Sigline Pro ($39 once) unlocks unlimited.

Try the formula generator — free

Related: How to write a SUMIF formula in Excel — for when the answer is a total, not a decision.