Logic function
Excel IF function
IF checks whether something is true, then returns one result if it is and another if it is not. Use it to label grades as Pass or Fail, flag overdue invoices, or calculate a bonus only when a target is met.
=IF(logical_test, [value_if_true], [value_if_false])Arguments
logical_test- The condition to check, like B2>=60. It must come out TRUE or FALSE.
value_if_true- What to return when the test is TRUE.
value_if_false- What to return when the test is FALSE. Leave it out and Excel returns FALSE.
IF examples
Every result below was calculated live from this sample sheet.
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | Submitted |
| 2 | Maya | 82 | Yes |
| 3 | Jordan | 54 | Yes |
| 4 | Priya | 91 | No |
| 5 | Leo | 67 | Yes |
Result: Pass
Maya scored 82, so the test is TRUE and IF returns "Pass".
Result: Fail
Jordan scored 54, so the test is FALSE and IF returns "Fail".
Result: 0
Priya did not submit, so she gets 0 instead of her score.
Result: D
Nested IFs check grade bands from the top down. Leo's 67 falls through to "D".
How to use IF
- Click the cell where the result should go.
- Type =IF( and write the condition, like B2>=60.
- Add a comma and the value to return when it is true.
- Add another comma and the value to return when it is false, then close the bracket.
Common IF mistakes
Forgetting quotes around text
Text results and text comparisons need double quotes: "Pass", not Pass. Without them Excel shows #NAME?.
Putting quotes around numbers
"100" is text, not a number. Write 100 so you can do math with the result.
Nesting too many IFs
Deep nests are hard to read and easy to break. Use IFS or a lookup table for more than three or four bands.
IF FAQ
How do I use IF with multiple conditions in Excel?
Put AND or OR inside the test. =IF(AND(B2>=60,C2="Yes"),"Pass","Fail") only passes when both conditions are true.
How do I make IF return a blank cell?
Use two double quotes as the result: =IF(B2="","",B2*2). The cell looks empty, though it actually holds empty text.
How many IF functions can you nest in Excel?
Excel allows up to 64 nested IFs. In practice, more than a few is hard to maintain, so switch to IFS, XLOOKUP, or a lookup table.
Can the Excel IF function check if a cell contains text?
Yes. =IF(ISNUMBER(SEARCH("urgent",A2)),"Flag","") checks whether the word appears anywhere in the cell.
Practice IF in these lessons
- Logic with IF: IF basics
- Clean results: Final challenge
- Data cleanup: Check your data
- Project: Sales commission report
- Project: Clean a CRM export
- Project: Inventory reorder alerts
Guides that use IF
- How to find duplicates in Excel
- How to compare two columns in Excel
- How to return multiple matches in Excel
- How to calculate percent change in Excel
- Excel IF statement with multiple conditions
- How to write a nested IF in Excel
- If a cell contains text, return a value in Excel
- How to use IF with AND and OR in Excel
Related functions
IFSFirst true test winsANDTrue if all tests are trueORTrue if any test is trueIFERRORFallback when a formula errors
Updated 2026-10-31