Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Logical Test: IF Function How-To Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To run a logical test in Excel, use the IF function: =IF(condition, value_if_true, value_if_false). For example, =IF(A2>=60, "Pass", "Fail") returns Pass when A2 is 60 or more, and Fail otherwise. That single line is the whole idea: Excel evaluates a condition and gives you one of two results. The rest of this guide covers how to build the condition correctly, how to nest and combine tests, and how to fix the errors people hit most often.

What You'll Need

  • Excel for Microsoft 365, Excel 2021, 2019, or 2016 on Windows or Mac, or Excel for the web. The IF function is available in every version, so no add-ins are required.
  • A worksheet with at least one column of values you want to test (numbers, dates, or text).
  • Basic familiarity with cell references such as A2 and with typing formulas into the formula bar.

Step-by-Step

  1. Pick the cell for the result. Click an empty cell next to your data, for example B2 if your values start in A2. This is where the formula's output will appear.
  2. Start the formula with an equals sign. Type =IF(. Excel will show a tooltip listing the three arguments: logical_test, value_if_true, and value_if_false. Argument names and separators can differ slightly by version and region; some locales use semicolons instead of commas.
  3. Write the logical test. This is a comparison that evaluates to TRUE or FALSE. Common operators are = (equal to), <> (not equal to), >, <, >=, and <=. For example, type A2>=60 to test whether the value in A2 is at least 60. Text comparisons need quotation marks around the text, as in A2="Yes".
  4. Add the value if true. Type a comma, then the result you want when the test passes. Text must be in double quotes, such as "Pass"; a number can be typed bare, such as 1; a cell reference such as C2 is also allowed.
  5. Add the value if false. Type a comma, then the result for a failed test, such as "Fail", then close the parenthesis. The finished formula looks like =IF(A2>=60, "Pass", "Fail").
  6. Press Enter and check the result. The cell shows Pass or Fail based on A2. Click the cell and look at the formula bar to confirm the formula is exactly as intended.
  7. Copy the formula down the column. Drag the fill handle (the small square at the bottom-right of the selected cell) down to apply the same test to each row. Relative references adjust automatically, so row 3 tests A3, row 4 tests A4, and so on.
  8. Handle blank cells if needed. An empty cell counts as zero in a numeric comparison, which can produce misleading results. To catch blanks first, use =IF(A2="", "No data", IF(A2>=60, "Pass", "Fail")). This nests a second IF inside the first.
  9. Combine conditions when one test is not enough. Use AND or OR inside the logical test. For example, =IF(AND(A2>=60, B2="Submitted"), "Complete", "Incomplete") returns Complete only when both conditions are true. Use OR when either condition should be enough.
  10. Use IFS for many outcomes. In Excel 2019 and later, including Microsoft 365 and Excel for the web, =IFS(A2>=90, "A", A2>=80, "B", A2>=70, "C", TRUE, "F") avoids deep nesting. Older versions do not have IFS, so use nested IFs there instead.

Common Mistakes

  • Forgetting quotes around text. =IF(A2=Yes, ...) fails because Excel looks for a named range called Yes. Write "Yes" instead.
  • Using the wrong comparison operator. A single = compares values; it does not assign them. Typing A2=>60 instead of A2>=60 causes an error.
  • Mismatched parentheses. Each IF needs one closing parenthesis, and nested IFs need one per level. Excel colours matching parentheses as you type, which helps you spot the mismatch.
  • Testing text against numbers. A number stored as text (often left-aligned in the cell) will not compare correctly with a numeric value. Convert it with Text to Columns or by retyping the value.
  • Hard-coding values that should be references. Writing =IF(A2>=60, "Pass", "Fail") in every row without adjusting the row number gives every row the same result. Copy the formula rather than retyping it.
  • Ignoring case sensitivity. IF comparisons are not case-sensitive by default. If case matters, use the EXACT function inside the test, as in =IF(EXACT(A2, "Yes"), ...).

Tips

  • Keep the logical test simple and put complex calculations in a helper column first; the formula stays readable and easier to debug.
  • Use cell references for thresholds (for example, a pass mark in a separate cell) so you can change the rule without editing every formula.
  • Press Ctrl+Shift+Enter only for older array formulas; ordinary IF formulas need just Enter.
  • Use the Evaluate Formula tool (Formulas tab) to step through a formula and see exactly which part returns TRUE or FALSE.
  • Format the result cells consistently so Pass and Fail stand out, for example with conditional formatting.

Troubleshooting

If the formula returns an error, check the message first. #VALUE! usually means a text value is being compared with a number, or a quoted string is missing. #NAME? almost always means text was typed without quotation marks or a function name is misspelled. #N/A can appear when a referenced cell is empty in a lookup-based test.

If the formula returns the wrong result, click the cell and inspect the formula bar. Confirm the cell reference points to the row you expect, and check that the comparison operator is the one you meant. Use Evaluate Formula to watch each argument resolve in turn.

If copying the formula gives identical results down the column, the references are likely absolute (with dollar signs) when they should be relative. Remove the dollar signs from the row part of the reference, or rewrite the formula so only the threshold is locked.

If the result shows as text rather than a value, check the cell's number format; a cell formatted as Text will display the formula as typed instead of calculating it. Change the format to General and re-enter the formula.

If nothing works, simplify: build the logical test alone in a spare cell (for example =A2>=60) and confirm it returns TRUE or FALSE. Once that is correct, wrap it back in the IF function.

Frequently Asked Questions

What does the IF function actually do?

It evaluates a condition and returns one value when the condition is true and another when it is false. The condition can compare numbers, text, dates, or the results of other functions.

Can I use IF with more than two outcomes?

Yes. Nest additional IF functions inside the value_if_false argument, or use the IFS function in newer versions of Excel. Nested IFs work in all versions but become hard to read after a few levels.

Why does my IF formula return FALSE instead of my text?

This happens when the value_if_false argument is left out. If you omit it, Excel returns FALSE when the test fails. Add a third argument such as "Fail" or an empty string "".

Is IF case-sensitive?

No. Text comparisons ignore case by default, so "yes" and "Yes" are treated as equal. Use EXACT inside the test if case matters.

Can I test whether a cell is blank?

Yes. Compare the cell with an empty string, as in =IF(A2="", "Blank", "Not blank"). This is useful before running numeric comparisons, because blank cells count as zero.

Does IF work the same in Excel for the web?

Yes, the core IF function behaves the same in Excel for the web, on Windows, and on Mac. Only newer functions such as IFS depend on the version, so check availability if you share the file with people on older releases.