IF in Excel: Syntax, Examples and Errors
Updated 2026-10-13 · Free · Works in Excel & Google Sheets
Syntax
=IF(logical_test, value_if_true, [value_if_false])Quick answer
IF returns one of two values depending on a test: =IF(B2>=50, "Pass", "Fail") shows Pass when B2 is at least 50 and Fail otherwise. Text results need double quotes; numbers and formulas go in bare. The third argument is optional — omit it and the formula returns FALSE, not a blank.
Syntax
=IF(logical_test, value_if_true, [value_if_false])| Argument | What it means |
|---|---|
| logical_test | The condition that comes out TRUE or FALSE: a comparison like B2>=50, an equality check like C2="Paid", or any expression that produces TRUE or FALSE. |
| value_if_true | What the formula returns when the test is TRUE — text in double quotes, a number, a date or another formula. |
| value_if_false | Optional. What to return when the test is FALSE. Omit it and IF returns the word FALSE; to show an empty cell instead, write empty quotes "". |
Depending on your regional settings, arguments are separated by semicolons instead of commas: =IF(B2>=50; "Pass"; "Fail"). This is standard in countries where the comma is the decimal separator.
Basic examples
=IF(B2>=50, "Pass", "Fail")The classic pass/fail test: every score of 50 or more shows Pass, everything below shows Fail. Text results always need double quotes, and the comparison operators (=, <>, >, >=, <, <=) sit inside the logical test, not in the result.
=IF(C2>1000, C2*0.1, 0)A 10% commission above 1,000, zero otherwise. Both results here are calculations, so no quotes anywhere — IF can return any formula, not just fixed values.
=IF(D2="", "Missing", D2*1.2)Checks for an empty cell first and flags it, otherwise runs the markup. Testing against "" is the standard way to catch blanks before doing math on them.
=IF(E2="Done", "Closed", "")Labels finished rows and leaves the rest truly blank. The empty quotes are what make the cell look empty — leaving the third argument out would print FALSE instead.
Numbers as results must not be quoted: =IF(A1>0, "50", 0) returns the text "50", which SUM and AVERAGE silently skip. Quote only text results; keep numbers, dates and formulas bare.
Common errors and how to fix them
| Symptom | Most common cause | Fix |
|---|---|---|
| #NAME? | IF is misspelled — or your Excel is set to another language, where the function has a localized name (SI, WENN, SE). | Type =I or =W and let autocomplete complete the name, or open the file in the matching language version of Excel. |
| The result literally shows FALSE | The third argument was left out, so IF prints FALSE whenever the test fails. | Add the value_if_false argument, or write "" if you want an empty cell instead. |
| Numbers arrive as text | The result was written in quotes: =IF(A1>0, "50", 0) returns text that SUM skips. | Remove the quotes around numeric results: =IF(A1>0, 50, 0). |
| #VALUE! appears in some rows | IF itself is fine — a formula inside the results, like D2*1.2, hits text or a blank in the source column. | Fix the source data, or guard the calculation: =IF(D2="", "Missing", D2*1.2). |
| Every row returns the same result | The logical test has no comparison: =IF(B2, "Yes", "No") treats any non-zero number as TRUE, and =IF(B2>50, ...) was written as =IF(B2=50, ...). | Write the full comparison (B2>50, B2<>""), and use = only when equality is what you mean. |
Invisible spaces cause the equal-text trap too: =IF(C2="Paid", ...) misses "Paid " with a trailing space. Clean the column first, then the comparison matches.
Nested IF vs. IFS
| Nested IF | IFS | |
|---|---|---|
| Conditions per formula | Unlimited, but every level adds a closing parenthesis | Up to 127 tests, written as plain pairs |
| Readability | Degrades fast beyond 3-4 levels | Conditions read top to bottom, no parentheses maze |
| Available in | Every Excel version (and Google Sheets) | Excel 2019+/365 (and Google Sheets) |
=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F")))The classic grade ladder: each condition falls through to the next IF when it fails. Read it inside-out, and mind that the closing parentheses pile up at the end — three nested IFs end with three of them.
=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", TRUE, "F")The same ladder in IFS: condition and result alternate as flat pairs, evaluated in order. There is no built-in else — the TRUE, "F" pair at the end acts as the catch-all, exactly like the last IF above.
IF in Google Sheets
Google Sheets supports IF with the same arguments and behavior as Excel, so the formulas above can be pasted over unchanged.
- The optional third argument behaves identically: omit it and Sheets also returns FALSE, not a blank.
- In regional settings that use a comma as the decimal separator (much of Europe and Latin America), type semicolons between arguments: =IF(B2>=50; "Pass"; "Fail"). Excel behaves the same way.
- Sheets also offers IFS with the same no-default-else quirk — end the list with TRUE, fallback to cover every remaining case.
- For many branches, both apps offer SWITCH, which compares one cell against a list of values and is far more readable than a deep IF ladder.
Limitations and pro tips
- IF returns a value; it cannot perform an action or "do nothing". For conditional formatting, filtering or deleting rows, use those features directly instead of an IF wrapper.
- Beyond 3-4 nested levels, switch to IFS, or replace the whole ladder with a lookup: =VLOOKUP(B2, $F$2:$G$5, 2, TRUE) maps score bands to grades in one row.
- Do not quote numeric results — quoted numbers become text and drop out of SUM, AVERAGE and charts.
- Omitting the third argument yields FALSE, not an empty cell: write "" explicitly when the blank look is the goal.
- Glue text and cells with &: =IF(B2>=50, "Passed with "&B2, "Failed with "&B2) builds a dynamic message without extra columns.
IF is only as reliable as the data it tests. Validate the column first — blanks, text-numbers and duplicates all silently flip results — then let the formula do its job.
Related Tools
Related Functions
Frequently Asked Questions
What does IF do in Excel?
It runs one test and returns one of two values: =IF(B2>=50, "Pass", "Fail") shows Pass when the test is TRUE and Fail when it is FALSE. The test can compare numbers, text or dates, and both results can be text, numbers, dates or whole formulas.
How do I write an IF formula that returns text?
Wrap the text in double quotes inside the formula: =IF(C2="Paid", "Yes", "No"). The quotes belong only to the result — if the cell then displays quotation marks, you have nested them inside the string by mistake.
Why does my IF formula return FALSE?
The third argument is missing: =IF(B2>50, "High") prints FALSE whenever the test fails. Add the value you want for FALSE — or write "" if you want the cell to look empty: =IF(B2>50, "High", "").
Can IF return a calculation instead of text?
Yes — put the formula in the result slot without quotes: =IF(C2>1000, C2*0.1, 0) returns 10% of C2 above 1,000, or zero. Both result slots accept any formula, including other IFs.
How do I use IF with multiple conditions?
Combine the tests with AND (all must be true) or OR (any one suffices): =IF(AND(B2>=50, C2<3), "Bonus", "No bonus"). For either-or logic swap AND for OR: =IF(OR(B2="", C2=""), "Missing", "OK").
How many IF functions can I nest?
Technically up to 64 in modern Excel, but readability collapses after 3-4 levels. Beyond that, use IFS for flat condition lists (Excel 2019+/365), or replace score-band ladders with a range lookup like =VLOOKUP(B2, $F$2:$G$5, 2, TRUE).
Does IF work in Google Sheets?
Yes — same name, same three arguments, same FALSE-when-omitted behavior. Only the argument separator changes in comma-decimal regional settings, where you type semicolons: =IF(B2>=50; "Pass"; "Fail").
Ready to try it on your own file?
Open Validate Excel Data — It's Free