How to use IF in Excel
Learn how Excel IF tests a condition and returns one value when TRUE and another when FALSE, with clear examples and practice.
Syntax
fx=IF(logical_test, value_if_true, [value_if_false])
Arguments
logical_test(required)A condition that evaluates to TRUE or FALSE, such as
B2>=50orA2="Done".value_if_true(required)The value or text to return when the condition is TRUE.
value_if_false(optional)The value or text to return when the condition is FALSE. If omitted, Excel returns FALSE.
What IF does
IF checks whether a condition is true or false, then returns one result if it is true and another if it is false. You use it to make decisions in your spreadsheet, such as flagging late tasks or calculating bulk discounts.
Return text based on a condition
To return words from an IF formula, wrap each text output in double quotes. In this table, an invoice unpaid after 30 days is overdue. The formula checks whether the days in B4 are 30 or fewer.
| Invoice | Days | Status |
| INV-101 | 14 | On time |
| INV-102 | 35 | Overdue |
| INV-103 | 21 |
Formula: =IF(B4<=30,"On time","Overdue") → On time
Return numbers from a formula
When returning numbers, do not use quotes. If you put quotes around a number, Excel treats it as text instead of a number. Here, orders of 5 or more units get free shipping (a 0 fee), while smaller orders pay 5.
| Order | Units | Shipping |
| #201 | 6 | 0 |
| #202 | 2 | 5 |
| #203 | 3 |
Formula: =IF(B4>=5,0,5) → 5
Common mistake: missing quotes around text
If you write =IF(B2>=50,Pass,Fail) without quotes, Excel looks for named ranges called Pass and Fail. When it cannot find them, it returns a #NAME? error. Always put text outputs in double quotes, such as "Pass" and "Fail". Cell references and numbers do not use quotes.