How to write an IF formula in Excel (with nested IF and IFS)
=IF(logical_test, value_if_true, value_if_false) returns one result when a condition is true and another when false.
Example: =IF(B2>=60,"Pass","Fail"). For many conditions, prefer IFS in Excel 365/2021+: =IFS(B2>=90,"A",B2>=80,"B",TRUE,"C").
Applies to all modern Excel versions. IFS requires Excel 2019/365 or later.
Build an IF formula
- Click the cell for the result.
- Type =IF( and enter a test such as B2>=60, then a comma.
- Type what to show if true (text in quotes or a number), then a comma.
- Type what to show if false, close the parenthesis and press Enter.
- Fill down the column as needed.
Nested IF vs IFS
Nested: =IF(B2>=90,"A",IF(B2>=80,"B","C")).
IFS: =IFS(B2>=90,"A",B2>=80,"B",TRUE,"C") - end with TRUE for a default.
AND / OR
=IF(AND(B2>=60,C2>=60),"Pass","Fail") =IF(OR(B2="VIP",C2>1000),"Priority","Normal")
IFERROR
=IFERROR(VLOOKUP(E2,A:C,3,FALSE),"Not found") shows a friendly message instead of #N/A.
Frequently asked questions
Wrong TRUE/FALSE text?
Put quotes around text results, and do not compare text to numbers accidentally.
Return blank?
Use "" as the true or false value.
IF vs SWITCH?
SWITCH compares one expression to listed values; IF/IFS handle inequalities better.