Smart Systems for Home

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

Excel IF Function: Operators and How to Use Them

· 7 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

The Excel IF function tests a condition and returns one value when the condition is true and another when it is false, and the operators inside that condition are what make it work. A comparison operator such as =, >, <, >= or <> sits between two values or cell references, and Excel evaluates it to TRUE or FALSE before IF picks which result to show. The basic pattern is =IF(A1>=60,"Pass","Fail"). Everything else in this guide is about getting the operator, the quotes and the brackets right.

One thing to know before you start: a comparison operator does not do arithmetic. If you want to add, subtract, multiply or divide inside the condition, that is a different set of symbols (+, -, *, /) and they can sit inside the test, for example =IF(B2*C2>100,"Over","Under"). The rule of thumb is that comparison operators ask a question and arithmetic operators do a calculation.

What You'll Need

  • Excel on Windows, Mac, the web or mobile, or a compatible spreadsheet app such as Google Sheets or LibreOffice Calc - the IF logic and comparison operators are the same, though the exact dialog wording can differ slightly by version.
  • Your data in columns with a clear header row, so you know which cells the condition should look at.
  • Text results wrapped in double quotes. Numbers and cell references are not quoted.
  • For nested tests, a notepad or scratch cell to sketch the logic before typing it, because bracket counting is where most errors come from.

Step-by-Step

  1. Pick the cell that should show the result. Click one cell to the right of your data, for example D2 if your values are in A2 to C2. Leave the row directly below it free so you can fill the formula down later.
  2. Start the formula with the equals sign and IF. Type =IF( and you should see the function name appear in the formula bar. Excel is not case-sensitive here, so =if( works identically.
  3. Write the logical test using the right comparison operator. The six you need are = (equal to), <> (not equal to), > (greater than), < (less than), >= (greater than or equal to) and <= (less than or equal to). Put a cell reference on the left and a value or another reference on the right, for example A2>=60 or B2<>"Closed".
  4. Add a comma, then the value to show when the test is true. Text goes in double quotes: "Pass". Numbers go bare: 1. A cell reference goes bare: C2. Your formula now reads =IF(A2>=60,"Pass".
  5. Add a second comma and the value for a false result. Finish with a closing bracket: =IF(A2>=60,"Pass","Fail"). Press Enter. The cell shows one of your two results immediately.
  6. Check the result against a row you can verify by eye. Find a row where you know the answer and confirm the cell agrees. If it does not, the operator is usually pointing the wrong way or the reference is wrong.
  7. Fill the formula down. Select the finished cell, then drag the small square handle at its bottom-right corner down the column, or double-click the handle to fill to the end of the adjacent data. Relative references such as A2 move to A3, A4 and so on automatically.
  8. Lock references that must not move. If every row should be compared against one threshold cell, such as F1, write it as $F$1 so filling down keeps it fixed. Without the dollar signs the threshold drifts and later rows compare against the wrong cell.
  9. Combine operators with AND or OR when you need two conditions. Write =IF(AND(A2>=60,B2="Active"),"Eligible","Check") to require both, or =IF(OR(A2>=90,B2="VIP"),"Priority","Standard") to accept either. AND and OR go inside the IF brackets, and each condition inside them is separated by a comma.
  10. Test the wording rules before you build long formulas. Put a quick trial in an empty cell: compare a cell to text with =IF(A2="Open",1,0) and confirm it returns 1. Text comparisons ignore capitalisation in Excel, so "open" and "Open" match.
  11. Handle blanks deliberately. An empty cell behaves as zero or an empty string depending on what you compare it with, which can make =IF(A2>=60,...) return a false result for a missing entry. Use =IF(A2="","No value",IF(A2>=60,"Pass","Fail")) so empty rows are labelled rather than scored.
  12. Audit a formula you cannot follow. Click the cell and use the formula bar to step through it, or use the Evaluate Formula tool on the Formulas tab in desktop Excel to see each part resolve one step at a time. On the web version, rebuilding the condition one piece at a time is the quickest check.

Common Mistakes

Quoting numbers or not quoting text. =IF(A2>="60","Pass","Fail") compares a number to the text string "60", which gives unpredictable results. Conversely, =IF(B2=Open,...) without quotes makes Excel look for a named range called Open and return a #NAME? error.

Using the wrong equals sign. Typing == or using = inside the condition where you meant >= is a frequent slip. A single = compares; a >= compares with an inclusive limit.

Missing a bracket. Every IF needs one closing bracket, and each nested IF or AND adds another. Excel usually refuses to accept the formula and offers to fix it - read the suggested fix rather than accepting blindly.

Forgetting the false argument. =IF(A2>=60,"Pass") is legal and returns FALSE when the test fails, which often looks like an empty cell or a confusing word in your report. Always supply the third argument unless you genuinely want FALSE.

Comparing text to numbers. If your imported data has numbers stored as text, a > comparison can misrank them. Align a suspect column and check whether the values sit left (text) or right (numbers).

Filling without locking the threshold. This is the classic quiet error: the top row is correct, the bottom rows are not, and nothing warns you.

Tips

Build formulas in stages. Start with just the condition in a cell, such as =A2>=60, confirm it returns TRUE or FALSE, and only then wrap it in IF. Keep comparison values in their own labelled cells rather than hard-coding them, so changing a threshold updates every result at once. Use named ranges for thresholds if the sheet is shared. If you need more than two outcomes, nested IFs work but get hard to read beyond three levels; a lookup table with VLOOKUP or XLOOKUP is usually cleaner. Finally, copy a finished formula into a text editor to check bracket balance - the colour-coded bracket highlighting in the formula bar only helps while the cursor is inside the formula.

Troubleshooting

The formula shows as text. The cell is formatted as Text. Select it, set the format to General, then re-enter the formula and press Enter - changing the format alone does not re-evaluate it.

You get #VALUE!. One of the values being compared is text where a number is expected, or a quoted numeric string is being used in a comparison. Check each reference for stray spaces and text-formatted numbers.

You get #NAME?. Either a function name is misspelled or an unquoted text value is being read as a name. Check that literal text has double quotes around it.

Every row returns the same answer. The threshold reference is probably not locked, or the fill copied absolute references that should have been relative. Check the first and last formula in the column side by side.

The result is right but in the wrong rows. Fill-down drag offsets references relative to the starting cell. If you started the formula on a different row than your first data row, the references shift by that amount.

The text comparison fails unexpectedly. Watch for trailing spaces, which can be imported from other systems. TRIM the source value or use =IF(TRIM(A2)="Open",...) instead. If that did not work, rewrite the condition from scratch in a blank cell rather than editing a long formula in place.

Frequently Asked Questions

What does <> mean in Excel IF?

It means not equal to. =IF(A2<>"Closed","Open case","Closed") returns "Open case" for any value except the exact word Closed.

Can I use more than one condition in an IF?

Yes, by wrapping conditions in AND or OR inside the IF. AND requires all conditions to be true; OR requires at least one.

Is IF case-sensitive?

No. Text comparisons ignore capitalisation, so "Open" and "open" are treated as equal. Use the EXACT function if case must match.

Why does my IF return FALSE instead of a blank?

You left out the third argument. Add a value after the second comma, such as "" for a blank result, and the cell will show that instead of FALSE.

Can I compare numbers stored as text?

Not reliably. Convert them to real numbers first, because text comparisons follow character order rather than numeric value.

What is the difference between = and >= in an IF?

= only matches an exact value, while >= matches that value and anything above it. For a pass mark of 60, =IF(A2>=60,...) includes 60; =IF(A2>60,...) excludes it.