Cellwise Try it free

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 from this sample sheet by the same spreadsheet engine the Cellwise app uses.

ABC
1StudentScoreSubmitted
2Maya82Yes
3Jordan54Yes
4Priya91No
5Leo67Yes
  1. =IF(B2>=60,"Pass","Fail")

    Result: Pass

    Maya scored 82, so the test is TRUE and IF returns "Pass".

  2. =IF(B3>=60,"Pass","Fail")

    Result: Fail

    Jordan scored 54, so the test is FALSE and IF returns "Fail".

  3. =IF(C4="Yes",B4,0)

    Result: 0

    Priya did not submit, so she gets 0 instead of her score.

  4. =IF(B5>=90,"A",IF(B5>=80,"B",IF(B5>=70,"C","D")))

    Result: D

    Nested IFs check grade bands from the top down. Leo's 67 falls through to "D".

How to use IF

  1. Click the cell where the result should go.
  2. Type =IF( and write the condition, like B2>=60.
  3. Add a comma and the value to return when it is true.
  4. 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

Guides that use IF

Related functions

Updated