ExcelUnpackUnpack Excel, one formula at a time.
Log inSign up

Lesson 30 · Logic

IF in Excel

IF lets a formula make a choice. It asks a yes-or-no question, then shows one answer if it is true and another if it is false. =IF(B2>=60,"Pass","Fail") is a classic.

Practice this lesson →Pro lesson. The first 4 lessons are free.

What you will learn

  • Compare numbers with signs like > and <
  • Pick one of two answers with IF

How it works

IF has three parts, split by commas:

  • the test (the question)
  • the answer if it's true
  • the answer if it's false

Signs: = equal, <> not equal, > greater than, < less than, >= greater than or equal to, <= less than or equal to.

Put words in quotes, like "Pass".

Formulas at a glance

=IF(test, if_true, if_false)The pattern to follow
=IF(B2>=60,"Pass","Fail")The pattern to follow

Example

Write the formula to show "Pass" if Ana's score is 60 or more. Otherwise show "Fail".

ABCDE
1StudentScoreResultBonusFinal
2Ana88
3Ben54
4Cleo95
5Dev61
6Eli47
7Fay77

Click C2 and type =IF(B2>=60,"Pass","Fail"), then press Enter.

The answer is Pass.

When to use it

  • Pass or Fail from a score
  • Showing "Over" when spending is above budget
  • Any label that depends on a number

Common mistakes

  • Leaving out the quotes on wordsWords go in quotes: "Pass".
  • Using => instead of >=The sign is >= (greater than or equal to).
  • Missing a commaIF has three parts split by two commas.

Quick check

Which formula shows "Yes" when A1 is more than 10?

  1. =IF(A1>10,"Yes","No")
  2. =IF("Yes",A1>10,"No")
  3. =IF(A1>10,Yes,No)
  4. =IF(A1>10)"Yes"
Show the answer

A. =IF(A1>10,"Yes","No") Test first. Then the true answer. Then the false answer. Words need quotes.

Practice it on a real sheet

Reading is a start. Doing it is how it sticks. This lesson walks you through every click on a live spreadsheet and checks each answer.

IF in Excel: how it works, with examples · ExcelUnpack