# IF function in Excel

> IF checks a condition and returns one value when it is true and another when it is false.

Source: https://spreadsheetpractice.com/functions/if · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

## Quick answer

- **What it does:** IF checks a condition and returns one value when it is true and another when it is false.
- **Syntax:** `=IF(logical_test, value_if_true, [value_if_false])`
- **Most common use:** `=IF(B2>=200,"Free shipping","Standard")` returns Free shipping (Text result based on a number test)
- **Available in:** Every current version
- **Category:** [Logical functions](https://spreadsheetpractice.com/functions/category/logic)
- **Returns:** Whichever of the two values matches the result of the test.
- **Google Sheets:** Works the same way in Google Sheets.

## What it does

IF checks a condition and returns one value when it is true and another when it is false. It is the building block for flags, tiers, bonuses and any rule you can phrase as "if this, then that". Combine it with AND or OR for several conditions, or move to IFS when there are more than two outcomes.

## Syntax

`=IF(logical_test, value_if_true, [value_if_false])`

| Argument | Required? | What it is |
|---|---|---|
| `logical_test` | Required | A comparison that is TRUE or FALSE, such as B2>=100 or C2="Paid". |
| `value_if_true` | Required | What to return when the test is TRUE: a number, text in quotes, a cell or another formula. |
| `value_if_false` | Optional | What to return when the test is FALSE. Left out, IF returns FALSE. |

## Examples

Each result was calculated by running the formula on the sample sheet.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| E2 | `=IF(B2>=200,"Free shipping","Standard")` | Free shipping | Text result based on a number test |
| E3 | `=IF(C3="No",B3*0.05,0)` | $4.25 | A calculation when the test is TRUE: a 5% late fee on an unpaid order |
| E4 | `=IF(AND(B4>500,C4="No"),"Call customer","")` | Call customer | Two conditions with AND; "" leaves the cell blank when the test fails |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Order | Total | Paid |  | Result |
| 2 | SO-1001 | $240 | Yes |  | Free shipping |
| 3 | SO-1002 | $85 | No |  | $4.25 |
| 4 | SO-1003 | $510 | No |  | Call customer |
| 5 | SO-1004 | $130 | Yes |  |  |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| #NAME? | Text results need double quotes: "Yes", not Yes. Without them Excel looks for a named range called Yes. |
| A test that should match but doesn't | C2="Yes" is FALSE when the cell holds "Yes " with a trailing space. Clean the column with TRIM, or test TRIM(C2)="Yes". |
| Tiers in the wrong order | In nested IFs, test the biggest threshold first: =IF(B2>=1000,"Gold",IF(B2>=500,"Silver","Bronze")). Testing >=500 first labels every 1,000+ customer Silver. |
| Writing a between test the math way | =IF(10<B2<20,...) is always FALSE in Excel. Split it: =IF(AND(B2>10,B2<20),...). |

## Tips

- Return "" to show a blank cell instead of 0 or FALSE.
- Compare against a cell, such as B2>=$H$1, instead of typing the threshold, so it can be changed in one place.

## Related functions

- [IFS](https://spreadsheetpractice.com/functions/ifs): IFS checks a list of conditions in order and returns the value paired with the first one that is TRUE.
- [SWITCH](https://spreadsheetpractice.com/functions/switch): SWITCH compares one value against a list of exact matches and returns the result paired with the first match, with an optional default at the end.
- [AND](https://spreadsheetpractice.com/functions/and): AND returns TRUE only when every condition you give it is TRUE.
- [OR](https://spreadsheetpractice.com/functions/or): OR returns TRUE when at least one of its conditions is TRUE.
- [IFERROR](https://spreadsheetpractice.com/functions/iferror): IFERROR returns a value you choose when a formula results in an error, and the formula's normal result otherwise.

## Questions

### How many IFs can you nest in Excel?

Up to 64, but anything past three or four is hard to check. Use IFS, SWITCH or an XLOOKUP against a small table instead.

### How do I use IF with two conditions?

Put AND or OR inside the test: =IF(AND(B2>100,C2="Paid"),"OK","Check") needs both conditions, and OR needs either one.

### Why does my IF formula return FALSE?

The test was FALSE and value_if_false was left out. Add a third argument, such as "" for a blank.

## Practice

A graded IF exercise ("Pass or fail") is on [the IF page](https://spreadsheetpractice.com/functions/if). It is checked instantly, then re-checked on changed data.

Lessons that use IF:

- [Lesson 5: The IF function](https://spreadsheetpractice.com/learn/if-function)
- [Lesson 6: AND, OR & IFS](https://spreadsheetpractice.com/learn/and-or-ifs)
- [Lesson 25: Tenure, quarters & weekdays](https://spreadsheetpractice.com/learn/tenure-quarters-weekdays) (Pro)
- [Lesson 28: LET](https://spreadsheetpractice.com/learn/let-function) (Pro)

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
