The Excel IF function checks whether a condition is true and returns one result if it is, and another result if it is false. For example, with a score in B2, =IF(B2>=60,"Pass","Fail") displays Pass when the score is at least 60 and Fail otherwise.
How the IF function works
IF is a logical function: it evaluates a test, then chooses between two outcomes. Its syntax is =IF(logical_test,value_if_true,value_if_false). The logical test can compare numbers, text, dates, or the result of another function. The two outcomes can be text in quotation marks, numbers, cell references, calculations, or other formulas.
For example, in =IF(B2>=60,"Pass","Fail"), B2>=60 is the test, "Pass" is returned when the test is true, and "Fail" is returned when it is false. The comparison operator >= means “greater than or equal to.” Common operators include:
=equal to<>not equal to>greater than<less than>=greater than or equal to<=less than or equal to
Excel evaluates the test for each row when you copy a formula down, adjusting relative references such as B2 to B3, B4, and so on. In Microsoft 365 for Windows, enter a formula in a cell and press Enter; drag the fill handle or double-click it to copy the formula down beside a continuous data range. Excel for Mac works similarly. If your regional settings use semicolons as list separators, Excel may require semicolons in formulas instead of the commas shown here.
Basic pass-or-fail and threshold examples
A common use is translating a numeric result into a clear category. Assume scores are in B2:B20 and a passing score is 60. In the row where B2 contains 72, use:
=IF(B2>=60,"Pass","Fail")
The result is Pass because 72 is at least 60. A score of 59 returns Fail. The comparison includes a score of exactly 60; changing the test to B2>60 would make 60 fail. This small operator choice matters at boundaries such as minimum grades, eligibility limits, and service targets.
IF can also return a calculated amount rather than a label. Assume sales are in B2, and the example pays 5% on sales of at least $1,000 and 2% on lower sales. With B2 equal to 1,200, use:
=IF(B2>=1000,B2*5%,B2*2%)
The result is 60, because 1,200 multiplied by 5% is 60. At sales of 800, the formula returns 16, or 800 multiplied by 2%. This is an illustrative calculation, not a recommendation for setting compensation. If rates or thresholds may change, store them in cells and refer to those cells rather than embedding the numbers in many formulas; that makes updates easier and reduces inconsistent edits.
Returning text, values, and blank-looking results
IF can test text as well as numbers. Assume payment status is in C2 and the cell contains Paid. To show a follow-up instruction for other statuses, use:
=IF(C2="Paid","Close","Follow up")
The result is Close for Paid and Follow up for any other value. Text in a formula must be enclosed in straight double quotation marks. A comparison such as this is generally not case-sensitive, so Paid and PAID match. Leading or trailing spaces can still cause unexpected results: a cell containing Paid may not behave like one containing Paid. Use consistent data entry or clean the source values if that is an issue.
Sometimes a formula should show nothing until its inputs are present. Assume A2 contains a quantity and B2 contains a unit price. With A2 equal to 3 and B2 equal to 12, this formula returns 36; if A2 is empty, it returns an empty text string:
=IF(A2="","",A2*B2)
An empty string makes the result look blank, but the cell still contains a formula. That distinction matters: some counting functions treat formula results differently from truly empty cells. Also, this formula checks only A2. If both quantity and price must be entered before calculating, test both inputs, for example with AND as described below.
Using IF with dates
Excel stores valid dates as serial numbers, so date comparisons work when the cells contain real Excel dates rather than text that merely looks like a date. Assume an expiration date is in B2 and the rule is that dates on or after January 1, 2026 are current. If B2 contains December 31, 2025, use:
=IF(B2>=DATE(2026,1,1),"Current","Expired")
The result is Expired. The DATE function creates a date value from year, month, and day, avoiding ambiguity between regional date formats. For a rolling test against today, assume B2 contains the date to evaluate:
=IF(B2>=TODAY(),"Not yet due","Past due")
This returns Not yet due when the date in B2 is today or later, and Past due when it is earlier. TODAY updates when Excel recalculates the workbook, so the displayed category can change over time without editing the formula. Check that dates are stored as dates; text dates may not compare as intended.
Combining conditions with AND and OR
IF normally makes one logical test, but AND and OR let that test include several criteria. AND is true only when every condition is true. Assume a score is in B2 and a completion status is in C2. A person is eligible only with a score of at least 80 and a status of Complete. For B2 equal to 85 and C2 equal to Complete, use:
=IF(AND(B2>=80,C2="Complete"),"Eligible","Not eligible")
The result is Eligible. If either condition fails—for example, the score is 79—the result is Not eligible. AND is useful for rules that require all criteria, such as a minimum score plus a completed training status.
OR is true when at least one condition is true. Assume an order’s priority is in C2 and its value is in B2. An order needs review if it is marked Urgent or its value is at least 500. With C2 equal to Normal and B2 equal to 600, use:
=IF(OR(C2="Urgent",B2>=500),"Review","Standard")
The result is Review because the value condition is true, even though the priority is Normal. Add parentheses carefully when combining AND and OR in more complex formulas so the intended grouping is clear. Building and checking each condition separately first can make a complicated test easier to troubleshoot.
Nested IF formulas for several outcomes
When a result needs more than two categories, one approach is to place another IF in an outcome. Assume a score is in B2 and the grading scale is A for 90 or higher, B for 80–89, C for 70–79, and D below 70. With B2 equal to 84, use:
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","D")))
The result is B. Excel tests the conditions from left to right: 84 is not at least 90, but it is at least 80, so the formula returns B without evaluating the later tests. Put thresholds in descending order for this pattern; a lower threshold placed first can capture values that should reach a higher category. Nested formulas are useful for a few outcomes, but they become difficult to read as conditions accumulate. For a long or frequently revised grading table, a lookup table can be easier to maintain.
Common IF mistakes and how to fix them
- Missing quotation marks around text: Write
"Pass", notPass. Without quotation marks, Excel may interpret the word as a name and return an error. - Reversing the true and false results: In
=IF(test,result_if_true,result_if_false), the second argument follows the test and the third is the alternative. Check that the outcomes are in the intended order. - Using the wrong boundary operator: Decide whether the threshold itself qualifies. Use
>=for “at least” and>for “more than.” - Testing numbers stored as text: A value that looks like 100 may be text rather than a number. Check the source data type and convert the data when necessary instead of relying on inconsistent implicit conversions.
- Confusing a blank result with a blank cell: Returning
""hides displayed content but leaves a formula in the cell. This can affect counts, filters, and later calculations. - Expecting IF to format a cell: IF returns a value; it does not change font color or fill color. To highlight cells based on a rule, use Home > Conditional Formatting and choose a suitable rule.
When a formula produces an unexpected answer, test the logical condition by itself in a spare cell or inspect the referenced cells. Confirm that the operator, spelling, spaces, and data types match the intended rule. If the formula is long, add one condition at a time and verify the result before extending it.
When to use IF, IFS, or IFERROR
Use IF when there are two outcomes, or when a small number of nested choices remains easy to read. AND and OR extend IF when several tests must be evaluated together. For many categories, a reference table and a lookup formula may be clearer than a deeply nested expression, particularly when thresholds change often.
IFS is another option for testing multiple conditions in order in versions that include the function, including Microsoft 365. It can make several-category formulas more readable, but check that the conditions cover the cases you expect; if none is true, IFS can return an error unless you include a final catch-all condition. IFERROR serves a different purpose: it returns an alternative when a formula evaluates to an error. It does not replace IF for ordinary true-or-false decisions. Choose based on whether the task is a two-way decision, several ordered categories, a lookup, or error handling.
Frequently Asked Questions
Can an IF formula return a number instead of text?
Yes. The true and false results can be numbers, calculations, or cell references. For example, the commission example returns a calculated numeric amount rather than a text label.
Can IF check whether a cell is blank?
Yes. A test such as A2="" checks whether the cell is empty or displays an empty string. Remember that a formula returning "" is not the same thing as a cell with no formula.
Can I use more than one condition in IF?
Yes. Put AND or OR in the logical-test argument to combine criteria. AND requires all its tests to be true; OR requires at least one.
Why does my IF formula show the formula instead of its answer?
Check whether the cell is formatted as Text, whether the formula begins with an apostrophe, and whether Show Formulas is enabled. Change a text-formatted cell to General, re-enter the formula, and toggle Show Formulas from the Formulas tab if needed.
Does IF distinguish uppercase and lowercase text?
Usually not: a standard equality test in IF is not case-sensitive. If case matters, use the case-sensitive EXACT function as the logical test, such as =IF(EXACT(A2,"Yes"),"Match","No match").
Related
- How to Remove a Dropdown List from an Excel Cell
- Remove a Dropdown List in Excel Without Losing Data
- Excel Redo Shortcut: How to Restore an Undone Action
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Day Value: Serial Dates and the DAY FunctionAn Excel day value can mean either the serial number Excel uses to store a date or the…
- Excel LAMBDA Examples for Reusable Custom FunctionsExcel’s LAMBDA function lets you turn a formula into a reusable custom function. For example, a definition with…
- Vlookup with multiple criteria?Learn how to use VLOOKUP with multiple criteria in Excel, build a reliable helper key, avoid common errors,…
- Excel FIND Function: How to Find Text Within a StringIn Excel, use FIND to locate text inside a string and return the position where it begins. For…
- Excel ROUND: Does It Round Positive or Negative Numbers?Excel’s ROUND function rounds both positive and negative numbers to the nearest value at the specified decimal place.…
- Excel Date Calculation Methods and FormulasIn Excel, calculate dates by adding or subtracting dates and day counts, or use functions such as DATE,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.