How IFs Work in Excel: Formulas and Examples

Formulas & functions · Updated November 20, 2026

In Excel, an IF formula tests a condition and returns one result when it is true and another when it is false; use IFS to test several conditions in order. If a score is in A2, for example, the formula =IF(A2>=70,"Pass","Review") returns Pass for a score of 70 or higher and Review otherwise.

What IF means in Excel

IF is a logical function: it asks Excel to evaluate a question whose answer is TRUE or FALSE, then choose an outcome based on that answer. This lets a worksheet apply a rule consistently across many rows, such as marking invoices overdue, checking whether a target was met, or assigning a category to a score.

The standard structure is =IF(logical_test, value_if_true, value_if_false). The logical test is the condition to check. The second argument is what Excel returns if the test is true, and the third is what it returns if the test is false. The false argument is optional; if you leave it out, Excel returns FALSE when the test fails. In most practical formulas, it is clearer to specify both outcomes.

IF returns a value in the cell containing the formula. It does not, by itself, recolor a cell or change its formatting. If the goal is to highlight cells visually, use conditional formatting instead. IF is useful when the result itself should appear in the worksheet, such as a label, number, date, or calculated amount.

How Excel evaluates an IF formula

Excel first evaluates the logical test. Common comparison operators are greater than (>), less than (<), equal to (=), greater than or equal to (>=), less than or equal to (<=), and not equal to (<>). The test can compare a cell with a number, text, a date, or another cell. Text values used directly in a formula need straight double quotation marks; cell references do not.

With a score of 82 in A2, the formula =IF(A2>=70,"Pass","Review") tests whether 82 is at least 70. Since the test is true, Excel returns Pass. If A2 held 64 instead, Excel would return Review. The formula does not change A2; it places the selected result in the cell where the formula is entered.

For another example, suppose B2 contains the number of items requested and C2 contains the number available. With 5 in B2 and 8 in C2, =IF(B2<=C2,"In stock","Back order") returns In stock because five items do not exceed the eight available. If the request were 10, the same test would be false and the result would be Back order.

When copying a formula down a column, ordinary references such as A2 adjust to A3, A4, and so on. If a rule should always refer to one fixed cell, use dollar signs to make an absolute reference, such as $F$1. This is useful for comparing every row with one shared threshold.

Writing and copying your first IF

Enter a formula in the cell where you want the result, beginning with an equals sign. You can type it directly in the cell or in the formula bar, then press Enter. Excel for Microsoft 365 on Windows uses commas between arguments in the examples here. In some regional settings, Excel expects semicolons instead; if a comma-separated formula is rejected, check the list separator used by your Excel installation.

  1. Decide what condition the formula should test, such as whether a value is at least a target.
  2. Choose a clear result for the true case and a useful result for the false case.
  3. Enter the IF formula in the result cell and check it against at least one example from each outcome.
  4. Copy it to other rows using the fill handle, the small square at the lower-right corner of the selected cell, or copy and paste.

For instance, if each row has a sales amount in B2 and the target is a fixed value in F1, the formula =IF(B2>=$F$1,"Target met","Below target") can be entered in C2 and filled down. The reference to B2 changes for each row, while $F$1 remains fixed. This makes the rule easier to maintain: change the target once in F1 rather than editing every formula.

Handling several conditions with AND and OR

A logical test can combine conditions. AND returns TRUE only when every condition supplied to it is true; OR returns TRUE when at least one supplied condition is true. Put either function inside IF when a decision depends on multiple criteria.

Suppose B2 contains a purchase amount and C2 contains an approval status. If the rule requires at least 100 and an approval marked Yes, then with B2 equal to 125 and C2 equal to Yes, =IF(AND(B2>=100,C2="Yes"),"Eligible","Not eligible") returns Eligible. If either requirement is not met, AND is false and IF returns Not eligible.

OR works for alternatives. If a task should be prioritized when its status in C2 is Urgent or its due date in D2 is earlier than today, the formula =IF(OR(C2="Urgent",D2<TODAY()),"Prioritize","Normal") returns Prioritize when either test is true. TODAY returns the current date, so the result can change as the date changes. For a fixed reporting date, comparing with a cell that contains that date may be more appropriate.

AND and OR can each take multiple conditions. Keep the logic readable: a formula with many tests can be difficult to review, so consider using helper columns to show intermediate checks or a lookup table when the rules become extensive.

Using nested IF and IFS for multiple outcomes

A nested IF places one IF inside another, allowing several outcomes. The order of tests matters: Excel checks the outer condition first, then proceeds into the next IF only if the preceding condition is false. Arrange thresholds so a higher range is tested before a lower one.

With a score in A2, the formula =IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","Needs review"))) returns B when A2 is 82. The first test, at least 90, is false; the next test, at least 80, is true. A score of 95 returns A, while a score below 70 reaches the final fallback, Needs review. This example assigns labels; it does not define a grading policy, so choose thresholds that match the rules you actually need.

IFS is another option for multiple tests and can be easier to scan than deeply nested IFs. With a score in A2, =IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"Needs review") also returns B for 82. IFS checks each condition from left to right and returns the result paired with the first true condition. The final TRUE acts as a catch-all; without a condition that matches, IFS returns the #N/A error. IFS is available in Microsoft 365 and newer Excel versions, including Excel 2019; older editions may not support it.

For a small number of outcomes, nested IF or IFS is often sufficient. For a long list of categories that changes regularly, a separate table of boundaries and labels can be easier to update than a long formula. The best choice depends on how many rules there are and whether people need to maintain them later.

Blank cells, text, and dates

Blank handling deserves care. To display a message when A2 is genuinely empty, =IF(ISBLANK(A2),"Missing","Entered") returns Missing for an empty cell and Entered when the cell contains a value. ISBLANK checks whether the cell is empty; it does not treat a formula that returns an empty string as a genuinely empty cell. If cells may contain formulas that display nothing, use a test such as =IF(A2="","Missing","Entered") instead, and verify that it behaves as intended with your data.

Text comparisons should match the values in the data. For example, checking whether C2 equals Yes will not match a different spelling such as Y or Approved. Excel’s ordinary text comparisons are generally not case-sensitive, so Yes and YES are treated as the same for this kind of comparison. If capitalization itself matters, a case-sensitive function such as EXACT can be used in the logical test.

Dates in Excel are stored as serial numbers, so date comparisons can use the same operators as numeric comparisons. Ensure the cells contain real Excel dates rather than text that merely looks like a date; text dates can produce unexpected comparisons. When testing a date against a specific date, a reference to a cell containing the date is often easier to read and maintain than embedding a date value in a formula.

Common IF errors and how to fix them

  • Reversed outcomes: Check that the true and false results are in the intended order. A correct test can still produce the wrong label if those two arguments are swapped.
  • Incorrect threshold order: In nested IF or IFS formulas, test the most restrictive or highest threshold first. Otherwise, a broad condition may match before Excel reaches the more specific one.
  • Text without quotation marks: Direct text results and text comparisons need double quotes. Without them, Excel may interpret a word as a name and return an error such as #NAME?.
  • Missing parentheses or separators: Each opening parenthesis needs a matching closing one, and arguments must use the separator configured for the installation.
  • Unexpected blank results: A formula may deliberately return an empty string, or the source cell may contain a formula that displays nothing. Check the underlying formula, not just what appears on the sheet.
  • IFS returns #N/A: Add a final catch-all condition and result, such as TRUE paired with a default label, if every possible value needs an outcome.

Test both sides of the rule, plus boundary values. For a threshold of 70, check 69, 70, and 71. This quickly reveals whether the condition should use greater than or equal to, rather than greater than alone. When formulas are long, use Excel’s formula bar to inspect the full expression and consider splitting complicated logic into helper columns.

IF versus conditional formatting and other approaches

Use IF when you need a calculated result: a status word, an adjusted number, or a decision that other formulas can use. Use conditional formatting when the underlying value should remain unchanged but its appearance should respond to a rule. In Microsoft 365 for Windows, conditional-formatting rules are available from Home > Conditional Formatting. For example, a rule can highlight values below a target without inserting a separate label column.

Use IFS rather than nested IF when there are several ordered conditions and you want each test-result pair to be visible in sequence. Use AND or OR inside IF when one decision depends on multiple requirements or alternatives. If many categories are maintained by nontechnical users, put the rules in a worksheet table and use an appropriate lookup approach rather than encoding every category in a lengthy chain. The key distinction is whether the rule is a short decision in a formula or a larger set of data that deserves its own structure.

Frequently Asked Questions

What is the basic IF formula in Excel?
The structure is =IF(logical_test, value_if_true, value_if_false). Excel checks the condition and returns the second argument if it is true, or the third if it is false.

Can an IF formula return text?
Yes. Put text results in straight double quotation marks inside the formula, such as Pass or Review. Cell references and numeric values do not need quotation marks.

What is the difference between IF and IFS?
IF chooses between a true result and a false result. IFS checks multiple conditions in order and returns the result paired with the first true condition. A final catch-all can prevent an unmatched value from producing #N/A.

Can Excel IF check more than one condition?
Yes. Put AND inside IF when all conditions must be true, or OR when any one condition is enough. Both functions can evaluate multiple logical tests.

Why does my IF formula show an error?
Check the quotation marks around text, the parentheses, the argument separator used by your regional settings, and whether each referenced cell contains the expected type of value. With IFS, also check that a catch-all condition is included if needed.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.