To do an IF then statement in Excel, use the IF function: =IF(logical_test, value_if_true, value_if_false). It reads as "if this is true, then show this, otherwise show that". For example, =IF(B2>=50,"Pass","Fail") shows Pass when B2 is 50 or more and Fail when it isn't. Type it in any cell and press Enter.
| Goal | Formula |
|---|---|
| Basic if then | =IF(B2>=50,"Pass","Fail") |
| Test text | =IF(C2="Paid","Closed","Chase") |
| Leave blank if false | =IF(D2>E2,D2-E2,"") |
| Two conditions (both) | =IF(AND(B2>=50,C2="Yes"),"Eligible","No") |
| Either condition | =IF(OR(B2>=90,C2="VIP"),"Priority","Standard") |
| Several outcomes | =IFS(B2>=70,"A",B2>=50,"B",TRUE,"C") |
How do I write an IF then statement in Excel?
Start with =IF(, add a test that is either true or false, then the result for true, then the result for false, separated by commas. Microsoft's IF function reference names these arguments logical_test, value_if_true and value_if_false. Only the first two are required.

Worked example. Exam scores are in column B:
| A (Student) | B (Score) | C (Result) | |
|---|---|---|---|
| 2 | Amira | 72 | Pass |
| 3 | Ben | 48 | Fail |
| 4 | Chloe | 50 | Pass |
| 5 | Dev | 31 | Fail |
- Click C2 and type
=IF(B2>=50,"Pass","Fail"). - Press Enter. C2 shows Pass, because 72 is at least 50.
- Select C2:C5 and press Ctrl+D to copy the formula down. Each row tests its own score.
The tests you can use are = (equal), <> (not equal), >, <, >= and <=. If you are new to formulas, our Excel tutorial for beginners explains cell references and filling formulas.
How do I use IF with text, numbers and blank cells?
Put text in double quotes and leave numbers bare. =IF(C2="Paid","Closed","Chase") compares text; the comparison is not case-sensitive, so "paid" also matches. =IF(B2>100,B2*0.1,0) works with numbers.
- To show nothing, return two quotes:
=IF(B2>=50,"Pass",""). - To test whether a cell is empty, use
=IF(A2="","Missing","OK")or=IF(ISBLANK(A2),"Missing","OK"). - To test whether a cell contains a word anywhere, combine ISNUMBER and SEARCH:
=IF(ISNUMBER(SEARCH("refund",D2)),"Refund","").
TRUE and FALSE are logical values, so don't put them in quotes when you want a real TRUE or FALSE result.
How do I write an IF statement with two conditions?
Put AND or OR inside the test. AND returns TRUE only when every condition is met; OR returns TRUE when at least one is.
=IF(AND(B2>=50,C2="Yes"),"Eligible","Not eligible") needs a score of 50 or more and "Yes" in C2. =IF(OR(B2>=90,C2="VIP"),"Priority","Standard") needs either one. You can also flip a test with NOT, for example =IF(NOT(C2="Closed"),"Open","").
What we commonly see: people write =IF(B2>=50 AND C2="Yes",...) as if it were plain English. Excel doesn't accept AND between two tests and returns an error. AND and OR are functions, so the conditions go inside their brackets, separated by commas.
How do I do a nested IF for more than two outcomes?
Put a second IF in the value_if_false slot of the first. Excel checks the tests in order and stops at the first one that is true. This grades a score into A, B or C:

=IF(B2>=70,"A",IF(B2>=50,"B","C"))
Order matters. Test the highest band first; if you check B2>=50 first, a score of 85 would stop there and get a B. Excel allows up to 64 nested IFs, but anything past three or four becomes hard to read and easy to break.
In Excel 2019 and later, the IFS function is cleaner. Each test is followed by its result, and a final TRUE acts as the "otherwise" value:
=IFS(B2>=70,"A",B2>=50,"B",TRUE,"C")
Without that final TRUE, IFS returns #N/A for any score that matches no test. When you are matching exact values rather than ranges, such as region codes, SWITCH is shorter still: =SWITCH(A2,"N","North","S","South","Other"). For long mapping lists, a lookup table with VLOOKUP is easier to maintain than any nested formula.
Can an IF statement return a calculation?
Yes. Either result can be a formula. This pays a 5% commission only when sales beat the target:
| B (Sales) | C (Target) | D (Commission) | |
|---|---|---|---|
| 2 | 12000 | 10000 | 600 |
| 3 | 8000 | 10000 | 0 |
The formula in D2 is =IF(B2>C2,B2*0.05,0). You can nest other functions too, such as =IF(SUM(B2:B13)>100000,"Bonus","").
Advanced nuance: if the same calculation appears in both the test and the result, as in =IF(SUM(B2:B13)>100000,SUM(B2:B13)*0.02,0), Excel 2021, Excel 2024 and Microsoft 365 let you name it once with LET: =LET(total,SUM(B2:B13),IF(total>100000,total*0.02,0)). It is easier to read and calculates the sum only once.
Why is my IF formula not working?
Check these common causes:

-
Numbers stored as text. If B2 holds "31" as text,
B2>=50returns TRUE, because Excel ranks any text above any number. Convert the column to real numbers first. - Curly quotes. Formulas pasted from a web page or Word can contain curly quotes, which cause errors. Retype them as straight quotes.
-
A 0 or FALSE result. If you leave out
value_if_false, IF returns FALSE. If you leave a result slot empty after a comma, it returns 0. Add the result you want, or""for blank. -
#NAME? Usually a misspelt function name or text without quotes, such as
=IF(C2=Paid,...). - The formula shows as text. The cell was formatted as Text before you typed it. Change it to General, then press F2 and Enter.
Do IF statements work the same in every Excel version?
IF, AND, OR and NOT work identically in every version of Excel, on Windows, Mac and the web. IFS and SWITCH need Excel 2019 or later, and LET needs Excel 2021 or later, so a workbook that uses them shows #NAME? if opened in Excel 2016. Keep to nested IFs if you share files with people on older versions.
Note that Office 2021 support ended on 13 October 2026, so Excel 2021 no longer gets security updates. If you're choosing a current one-time-purchase version, the Office 2024 collection lists the editions that include Excel. And if you need IF logic inside automation, our guide to Excel macros shows the VBA If...Then...Else structure.
Frequently asked questions
What is the difference between IF and IFS in Excel?
IF tests one condition and returns one of two results, so several outcomes require nesting one IF inside another. IFS takes pairs of tests and results in a flat list and returns the result for the first true test. IFS is easier to read for three or more outcomes but needs Excel 2019 or later, while IF works in every version.
How do I make an IF formula return a blank cell?
Use two double quotes as the result: =IF(A2>0,A2*2,""). The cell looks empty, although technically it contains an empty text string. That matters for COUNTA, which counts it, and for ISBLANK, which returns FALSE for it. Test for ="" rather than ISBLANK when checking cells filled by such formulas.
Can I use IF with dates in Excel?
Yes, but don't type a date directly into the test as text. Use the DATE function or a cell reference: =IF(B2<DATE(2026,12,31),"Due","Later") or =IF(B2<TODAY(),"Overdue",""). Excel stores dates as numbers, so the usual comparison operators work once both sides are real dates rather than text.
How many IF statements can you nest in Excel?
Excel allows up to 64 levels of nested IF functions in one formula. In practice, more than three or four makes formulas difficult to check and fix. For several bands, use IFS in Excel 2019 or later, or build a small lookup table and use VLOOKUP with an approximate match, which handles any number of bands cleanly.
Is there an IF then else in Excel?
Yes, the IF function already is an if-then-else. The second argument is the "then" result and the third argument is the "else" result: =IF(test,then,else). For "else if" logic, nest another IF in the third argument or use IFS. In VBA macros, Excel uses an If...Then...ElseIf...Else...End If block instead.
Related guides
- What is VLOOKUP in Excel?
- Excel keyboard shortcuts you'll actually use
- What is a macro in Excel?
- Excel 2024 vs Excel in Microsoft 365
Links in this guide
| Link | Type | Why it helps |
|---|---|---|
| Microsoft Support: IF function | External | Official syntax and examples |
| Excel tutorial for beginners | Internal | Formula and fill-down basics |
| Microsoft Support: IFS function | External | Official reference for multiple conditions |
| What is VLOOKUP in Excel? | Internal | Lookup tables as an alternative to long nested IFs |
| Office 2024 licence keys | Internal | Current editions that include Excel |
| What is a macro in Excel? | Internal | VBA If...Then...Else structure |
| Excel keyboard shortcuts | Internal | Fill formulas down quickly |
| Excel 2024 vs Excel in Microsoft 365 | Internal | Which logical functions each version has |
