---
title: "IF function in Excel: syntax and examples | ExcelSavvy"
description: "How to use IF in Excel and Google Sheets: pass/fail, multiple conditions, if a cell contains text and nested IFs. Syntax, examples and live drills."
canonical_url: "https://excelsavvy.com/functions/if"
meta:
  "og:description": "How to use IF in Excel and Google Sheets: pass/fail, multiple conditions, if a cell contains text and nested IFs. Syntax, examples and live drills."
  "og:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBtdWx0aXBsZSBjb25kaXRpb25zLCBpZiBhIGNlbGwgY29udGFpbnMgdGV4dCBhbmQgbmVzdGVkIElGcy4gU3ludGF4LCBleGFtcGxlcyBhbmQgbGl2ZSBkcmlsbHMu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_3SHrUlW-1-nKtagy.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "IF function in Excel: syntax and examples | ExcelSavvy"
  "twitter:image": "https://excelsavvy.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBtdWx0aXBsZSBjb25kaXRpb25zLCBpZiBhIGNlbGwgY29udGFpbnMgdGV4dCBhbmQgbmVzdGVkIElGcy4gU3ludGF4LCBleGFtcGxlcyBhbmQgbGl2ZSBkcmlsbHMu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_3SHrUlW-1-nKtagy.png"
---

> Index of every page on this site: [llms.txt](https://excelsavvy.com/llms.txt)

# **The IF function**

Returns one value when a test is TRUE and another when it is FALSE. Put text results in double quotes.

=

IF(

## **How to use IF**

IF is the yes-or-no question of spreadsheets. You give it a test, and it answers with one thing when the test is TRUE and another when it is FALSE. Think of a bouncer with a guest list: if you are on the list, you go in, otherwise you don't.

Reach for IF whenever one cell should depend on another. Mark invoices as paid or open, show a bonus only above a sales target, or flag staff who have not handed in a timesheet. The test is usually a comparison such as `**A2>=50**`, `**B2="Paid"**` or `**C2<>""**`. Text results go in double quotes, numbers do not: `**=IF(B2>10000,B2*0.05,0)**`.

When one test is not enough, put AND or OR inside it: `**=IF(AND(B2>=50,C2="Yes"),"Pass","Fail")**`. For three or more outcomes you can nest IFs, but IFS is easier to read. If the outcomes sit in a list you may change later, a lookup table with VLOOKUP or XLOOKUP is better still. If you leave out the third argument, IF returns FALSE when the test fails.

## **Syntax**

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

<dl><dt>**logical_test **</dt>
<dd>A comparison that is TRUE or FALSE, such as A2&gt;=50.</dd>
<dt>**value_if_true **(optional)</dt>
<dd>What to return when the test is TRUE.</dd>
<dt>**value_if_false **(optional)</dt>
<dd>What to return when the test is FALSE.</dd></dl>

## **Examples**

C1`=IF(<sup>1</sup>A2>=50,<sup>2</sup>"Pass",<sup>3</sup>"Fail")`

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Score |  | **Pass** |
| 2 | 62 |  | |

**In plain words:** <sup>1</sup>If the score in A2 is 50 or more, <sup>2</sup>show Pass. <sup>3</sup>Otherwise show Fail.

C1=IF(A2>100,A2\*0.1,0)

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Score |  | **0** |
| 2 | 62 |  | |

C1`=IF(<sup>1</sup>ISNUMBER(SEARCH("pro",A2)),<sup>2</sup>"Pro",<sup>3</sup>"Standard")`

|  | A | B | C |
| --- | --- | --- | --- |
| 1 | Product |  | **Pro** |
| 2 | Laptop PRO 14 |  | |

**In plain words:** <sup>1</sup>If the product name in A2 contains pro, <sup>2</sup>show Pro. <sup>3</sup>Otherwise show Standard.

## **Common IF mistakes**

- IF shows #NAME? instead of my text

  Text in the test and in the results needs double quotes, as in `**=IF(A2="Paid","Done","Open")**`. Without quotes, the program reads Paid as a name it does not know.
- The test never matches a number I can clearly see

  Either the number sits in quotes in the formula ( `**"50"**` is text) or the cell holds a number stored as text, which is usually left-aligned. Write `**=IF(A2=50,"Yes","No")**` without quotes, or convert the cell first with `**=IF(VALUE(A2)>=50,"Pass","Fail")**`.
- Every row gets the same result from my nested IF

  IF checks the tests from the outside in and stops at the first TRUE. Start with the strictest one: `**=IF(A2>=90,"High",IF(A2>=60,"Mid","Low"))**`. If you test A2>=60 first, every score of 90 or more also ends up as Mid.
- I get #VALUE! when I add up cells that IF left "empty"

  The result `**""**` looks empty but is text, and `**=C2+D2**` cannot add text. Use `**=SUM(C2:D2)**`, which skips text, or return 0 instead of `**""**` and hide the zeros with a number format.

## **Practice IF**

- [**1****Pass or fail with IF**→](https://excelsavvy.com/practice/if/if-pass-fail)
- [**2****Calculate a bonus with IF**→](https://excelsavvy.com/practice/if/if-calculate-bonus)
- [**3****Three outcomes with nested IF**→](https://excelsavvy.com/practice/if/nested-if)
- [**4****Compare two cells with IF**→](https://excelsavvy.com/practice/if/if-compare-two-cells)
- [**5****IF a cell contains a word**→](https://excelsavvy.com/practice/if/if-cell-contains-text)

## **Read the guide**

- [**Excel test for a job interview: what it looks like and how to practice**](https://excelsavvy.com/learn/excel-for-job-interviews)
- [**Free Excel course online: learn Excel from your first formula to job-ready**](https://excelsavvy.com/learn/how-to-learn-excel)
- [**Excel IF formulas: from one condition to many**](https://excelsavvy.com/learn/excel-if-function)
- [**Excel budget template: free download and the formulas behind it**](https://excelsavvy.com/learn/excel-budget-template)

## **Questions**

<details>

<summary>

### How do I check if a cell contains text?

</summary>

IF doesn't understand wildcards, so combine it with SEARCH and ISNUMBER, =IF(ISNUMBER(SEARCH("pro",A2)),"Pro","Standard"). SEARCH ignores case, and FIND tells capitals apart. To check whether a cell holds any text at all, use =IF(ISTEXT(A2),"Text","Not text").

</details>

<details>

<summary>

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

</summary>

Put AND or OR in the test. =IF(AND(B2&gt;=50,C2="Yes"),"Pass","Fail") needs both to be true, and =IF(OR(B2&gt;=90,C2="Yes"),"Bonus","") needs one of them. For more than two outcomes, nest IFs or use IFS.

</details>

<details>

<summary>

### How do I check if a cell is empty with IF?

</summary>

Compare the cell with two double quotes, =IF(A2="","Missing","OK"), or use ISBLANK, =IF(ISBLANK(A2),"Missing","OK"). A2="" is also TRUE when A2 holds empty text from another formula, while ISBLANK is TRUE only for a truly empty cell.

</details>

<details>

<summary>

### How do I leave the cell blank when the condition is not met?

</summary>

Use two double quotes as the result, as in =IF(B2&gt;10000,B2\*0.05,""). The cell looks empty, but it holds empty text, so ISBLANK returns FALSE for it.

</details>

<details>

<summary>

### How many IFs can I nest?

</summary>

Excel allows 64, but past three or four the formula is hard to read. Use IFS, or a lookup table with VLOOKUP or XLOOKUP, instead.

</details>

## **Related functions**

- [**IFS**](https://excelsavvy.com/functions/ifs)
- [**AND**](https://excelsavvy.com/functions/and)
- [**OR**](https://excelsavvy.com/functions/or)
- [**IFERROR**](https://excelsavvy.com/functions/iferror)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://excelsavvy.com/#identity","@type":"Organization","name":"ExcelSavvy","url":"https://excelsavvy.com/","logo":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/#website","@type":"WebSite","inLanguage":"en-US","name":"ExcelSavvy","url":"https://excelsavvy.com/","alternateName":["Excel Savvy","ExcelSavvy.com","PracticeExcel","Practice Excel Online"],"publisher":{"@id":"https://excelsavvy.com/#identity"},"workTranslation":[{"@id":"https://excelopgaver.dk/#website"},{"@id":"https://excelpraxis.de/#website"}]},{"@id":"https://excelsavvy.com/functions/if#webpage","dateModified":"2026-11-16","description":"How to use IF in Excel and Google Sheets: pass/fail, multiple conditions, if a cell contains text and nested IFs. Syntax, examples and live drills.","name":"IF function in Excel: syntax and examples","url":"https://excelsavvy.com/functions/if","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://excelsavvy.com/functions/if#breadcrumb"},"isPartOf":{"@id":"https://excelsavvy.com/#website"},"mainEntity":[{"@id":"https://excelsavvy.com/functions/if#/schema/question/1"},{"@id":"https://excelsavvy.com/functions/if#/schema/question/2"},{"@id":"https://excelsavvy.com/functions/if#/schema/question/3"},{"@id":"https://excelsavvy.com/functions/if#/schema/question/4"},{"@id":"https://excelsavvy.com/functions/if#/schema/question/5"}],"potentialAction":[{"@type":"ReadAction","target":["https://excelsavvy.com/functions/if"]}],"primaryImageOfPage":{"@id":"https://excelsavvy.com/#logo"}},{"@id":"https://excelsavvy.com/functions/if#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://excelsavvy.com","position":1},{"@type":"ListItem","name":"Excel functions","item":"https://excelsavvy.com/functions","position":2},{"@type":"ListItem","name":"IF function in Excel: syntax and examples","position":3}]},{"@id":"https://excelsavvy.com/functions/if#article","dateModified":"2026-11-16","description":"How to use IF in Excel and Google Sheets: pass/fail, multiple conditions, if a cell contains text and nested IFs. Syntax, examples and live drills.","headline":"IF function in Excel: syntax and examples","inLanguage":"en-US","thumbnailUrl":"https://excelsavvy.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBtdWx0aXBsZSBjb25kaXRpb25zLCBpZiBhIGNlbGwgY29udGFpbnMgdGV4dCBhbmQgbmVzdGVkIElGcy4gU3ludGF4LCBleGFtcGxlcyBhbmQgbGl2ZSBkcmlsbHMu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_3SHrUlW-1-nKtagy.png","@type":["Article","TechArticle"],"author":{"@id":"https://excelsavvy.com/#identity"},"image":{"@id":"https://excelsavvy.com/#/schema/image/1"},"isPartOf":{"@id":"https://excelsavvy.com/functions/if#webpage"},"mainEntityOfPage":{"@id":"https://excelsavvy.com/functions/if#webpage"},"publisher":{"@id":"https://excelsavvy.com/#identity"}},{"@id":"https://excelsavvy.com/functions/if#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"How do I check if a cell contains text?","acceptedAnswer":{"@type":"Answer","text":"IF doesn't understand wildcards, so combine it with SEARCH and ISNUMBER, =IF(ISNUMBER(SEARCH(\"pro\",A2)),\"Pro\",\"Standard\"). SEARCH ignores case, and FIND tells capitals apart. To check whether a cell holds any text at all, use =IF(ISTEXT(A2),\"Text\",\"Not text\")."}},{"@id":"https://excelsavvy.com/functions/if#/schema/question/2","@type":"Question","inLanguage":"en-US","name":"How do I use IF with multiple conditions?","acceptedAnswer":{"@type":"Answer","text":"Put AND or OR in the test. =IF(AND(B2>=50,C2=\"Yes\"),\"Pass\",\"Fail\") needs both to be true, and =IF(OR(B2>=90,C2=\"Yes\"),\"Bonus\",\"\") needs one of them. For more than two outcomes, nest IFs or use IFS."}},{"@id":"https://excelsavvy.com/functions/if#/schema/question/3","@type":"Question","inLanguage":"en-US","name":"How do I check if a cell is empty with IF?","acceptedAnswer":{"@type":"Answer","text":"Compare the cell with two double quotes, =IF(A2=\"\",\"Missing\",\"OK\"), or use ISBLANK, =IF(ISBLANK(A2),\"Missing\",\"OK\"). A2=\"\" is also TRUE when A2 holds empty text from another formula, while ISBLANK is TRUE only for a truly empty cell."}},{"@id":"https://excelsavvy.com/functions/if#/schema/question/4","@type":"Question","inLanguage":"en-US","name":"How do I leave the cell blank when the condition is not met?","acceptedAnswer":{"@type":"Answer","text":"Use two double quotes as the result, as in =IF(B2>10000,B2*0.05,\"\"). The cell looks empty, but it holds empty text, so ISBLANK returns FALSE for it."}},{"@id":"https://excelsavvy.com/functions/if#/schema/question/5","@type":"Question","inLanguage":"en-US","name":"How many IFs can I nest?","acceptedAnswer":{"@type":"Answer","text":"Excel allows 64, but past three or four the formula is hard to read. Use IFS, or a lookup table with VLOOKUP or XLOOKUP, instead."}},{"@id":"https://excelsavvy.com/#logo","@type":"ImageObject","caption":"ExcelSavvy","contentUrl":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3","inLanguage":"en-US","url":"https://excelsavvy.com/brand/practiceexcel/icon-512.png?v=3"},{"@id":"https://excelsavvy.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://excelsavvy.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBtdWx0aXBsZSBjb25kaXRpb25zLCBpZiBhIGNlbGwgY29udGFpbnMgdGV4dCBhbmQgbmVzdGVkIElGcy4gU3ludGF4LCBleGFtcGxlcyBhbmQgbGl2ZSBkcmlsbHMu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_3SHrUlW-1-nKtagy.png","inLanguage":"en-US","url":"https://excelsavvy.com/_og/d/c_Page%2Ctitle_~SUYgZnVuY3Rpb24gaW4gRXhjZWw6IHN5bnRheCBhbmQgZXhhbXBsZXM%2Cdescription_~SG93IHRvIHVzZSBJRiBpbiBFeGNlbCBhbmQgR29vZ2xlIFNoZWV0czogcGFzcy9mYWlsLCBtdWx0aXBsZSBjb25kaXRpb25zLCBpZiBhIGNlbGwgY29udGFpbnMgdGV4dCBhbmQgbmVzdGVkIElGcy4gU3ludGF4LCBleGFtcGxlcyBhbmQgbGl2ZSBkcmlsbHMu%2Ceyebrow_Excel%2Bfunctions%2Csite_practiceexcel%2Ccode_~SUYobG9naWNhbF90ZXN0LCBbdmFsdWVfaWZfdHJ1ZV0sIFt2YWx1ZV9pZl9mYWxzZV0p%2Cp_Ii9mdW5jdGlvbnMvaWYi%2Cs_3SHrUlW-1-nKtagy.png"}]}
```

## Sitemap

See the full [sitemap](https://excelsavvy.com/sitemap.md) for all pages.
