The IF function in Excel evaluates a condition and returns one value if the condition is true and another if it is false. The syntax is =IF(logical_test, value_if_true, value_if_false). A basic example is =IF(A2>=60, "Pass", "Fail"), which returns "Pass" when A2 is at least 60 and "Fail" otherwise. Excel has no separate THEN or ELSE keywords: the middle argument acts as THEN and the last argument acts as ELSE, separated by commas.
What You'll Need
- Excel for Microsoft 365, Excel 2021/2019, Excel for Mac, or Excel on the web. The function behaves the same across all of these.
- Data arranged in cells you can reference, for example scores in column A and names in column B.
- A number format you are happy with, since text results appear exactly as typed.
- No add-ins or special setup: IF is built into every version of Excel.
Step-by-Step
- Choose where the result goes. Click the cell where you want the answer, such as C2 next to your first row of data.
- Start the formula. Type
=IF(and note that Excel shows a tooltip listing the three arguments as you type. - Write the test. Enter a comparison using one of these operators:
=equal,>greater than,<less than,>=greater or equal,<=less or equal,<>not equal. For exampleA2>=60. Text comparisons need quotes:A2="Yes". - Add the true result. After the comma, type what should appear when the test passes. Put text in double quotes:
"Pass". Numbers can be entered bare, like1. - Add the false result. After the second comma, type the alternative:
"Fail". Close the bracket. - Confirm the full formula. It should read
=IF(A2>=60, "Pass", "Fail"). Press Enter. The cell shows "Pass" or "Fail" based on the value in A2. - Copy it down the column. Drag the fill handle at the bottom-right corner of the cell downward, or copy the cell and paste it into the rows below. Relative references adjust so each row tests its own value.
- Test the edge cases. Type a value exactly equal to your threshold, a value just below it, and a blank cell. A blank cell counts as zero in a numeric test, so an empty row may return the false result (or the true result if your test is
<60). - Add a third outcome with nested IFs. For grades, use
=IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", "F"))). Each inner IF sits in the false position of the one before it. Excel allows 64 nested levels, but more than three or four becomes hard to read and audit. - Handle false conditions with AND or OR. To require two tests, wrap them:
=IF(AND(A2>=60, B2="Paid"), "Approve", "Review"). For either test, use OR in the same position. - Return a blank instead of a zero. Use
""as the false value:=IF(A2="", "", A2*1.1). This keeps empty rows visually clean. - Check the result format. If your true or false value is text but the cell shows a number, or vice versa, verify the quotes are straight double quotes, not curly quotes copied from a document.
Common Mistakes
- Missing quotes around text.
IF(A2>=60, Pass, Fail)produces a #NAME? error because Excel reads Pass as an undefined name. Wrap text in double quotes. - Wrong argument count. Forgetting the false value is allowed (Excel returns FALSE), but adding a fourth argument or leaving a stray comma gives "You've entered too many arguments for this function."
- Using then/else words. Typing
=IF(A2>=60 THEN "Pass" ELSE "Fail")imports habits from programming languages and will not parse. Commas do the job. - Commas versus semicolons. Some regional settings use semicolons as the argument separator:
=IF(A2>=60; "Pass"; "Fail"). If Excel rejects a comma formula, check your locale or type the formula and let Excel show the separator it expects. - Nested IFs in the wrong order. In a chain of thresholds, test from the highest down. Testing
A2>=70beforeA2>=90makes every score of 90 become a C. - Text versus numbers. Values pasted from other systems may be stored as text.
A2>=60on text "75" can compare incorrectly, and "60" is not equal to 60. Convert with VALUE or re-enter the numbers. - Curly quotes. Copying a formula from a blog or chat can insert smart quotes, which Excel treats as part of the text. Retype the quotes.
Tips
- Keep the logical test simple and put complex maths in a helper column. It makes the IF readable and easier to audit.
- Use named ranges for thresholds, such as a cell holding the pass mark, so you change one cell instead of every formula.
- For three or more outcomes, IFS is cleaner than nested IFs:
=IFS(A2>=90, "A", A2>=80, "B", TRUE, "F"). The final TRUE acts as the catch-all else. - Add a blank test first when rows can be empty, so your formula does not compute on nothing.
- Check results on a few rows manually before filling the whole column; an error in the test is much cheaper to fix early.
Troubleshooting
If the cell shows the formula instead of the result, the cell is formatted as Text. Select it, set the number format to General, press F2 and then Enter. If you see #NAME?, you likely have unquoted text or a mistyped function name. If you see #VALUE!, check for text in a numeric test or a stray space inside a number. If the result is wrong rather than an error, walk through the formula in the formula bar and confirm each reference points to the row you expect; copied formulas with absolute references ($A$2) will not adjust. For a formula that worked yesterday but not today, run Formulas > Show Formulas to see everything at once, and check whether values were pasted as text. If nothing obvious appears, evaluate the parts by retyping the logical test alone in a blank cell, for example =A2>=60, which returns TRUE or FALSE and isolates the problem.
Frequently Asked Questions
Does Excel have a real THEN keyword?
No. The second argument of IF is the THEN part and the third is the ELSE part. They are separated by commas, not by words.
Can I leave out the else part?
Yes. =IF(A2>=60, "Pass") returns FALSE when the test fails. A common alternative is to place an empty string, "", in the false position.
How many IFs can I nest?
Current Excel versions allow up to 64 nested IFs. In practice, use IFS or a lookup table once you get past three or four outcomes.
Why does my formula return FALSE instead of nothing?
You probably missed the third argument. Add a value for the false result, or "" for a blank.
Can IF return a different formula or cell?
Yes. The true and false parts can be calculations, cell references or other functions, such as =IF(A2>=60, B2*1.1, B2). Both results are still evaluated by Excel in some cases, so keep them lightweight.
Is IF case-sensitive?
No, text comparisons in IF are not case-sensitive, so "yes" matches "Yes". Use the EXACT function inside the test if case matters.