An IF calculation in Excel tests a condition and returns one result when it is true and another when it is false. The basic form is =IF(logical_test, value_if_true, value_if_false), so =IF(A1>50,"Pass","Fail") shows Pass when A1 is above 50 and Fail otherwise. You need nothing more than Excel (or Excel for the web) and a sheet with at least one value to test. The notes below apply to the desktop and web versions of Excel; menu labels can differ slightly by version and region.

What You'll Need

  • A spreadsheet in Excel for Windows, Mac or the web. Google Sheets and LibreOffice use the same syntax if you are working there instead.
  • At least one cell containing a number, date or text value to test.
  • A cell to hold the formula's output, which is where you enter it.
  • Optional: a second or third cell if you want the formula to compare two values.

Step-by-Step

  1. Click the cell where the result should appear. This is the output cell, not the cell holding the data. Everything you type next goes into it.
  2. Type =IF(. The equals sign tells Excel this is a formula, and the opening bracket starts the function. Excel usually shows a tooltip listing the arguments as you go.
  3. Write the test first. A test compares two things with an operator: > (greater than), < (less than), >=, <=, = (equal to) or <> (not equal to). For example, type A1>50 to ask whether the value in A1 is above 50. Note that a single = inside the brackets means equal to, while the = at the very start only begins the formula.
  4. Add a comma, then the true result. After the test, type a comma and then what should appear when the test passes. Text results must be in double quotes, so "Pass". A number needs no quotes, so 100. You can also point at another cell, such as B1.
  5. Add a comma, then the false result. Type the value for when the test fails, for example "Fail". The whole formula now reads =IF(A1>50,"Pass","Fail").
  6. Close the bracket and press Enter. Excel checks the formula and displays the result. If it shows a green triangle in the corner, hover over the cell and a short explanation will appear.
  7. Copy the formula down the column if needed. Drag the small square in the bottom-right corner of the cell, or copy the cell and paste it into the cells below. Relative references adjust automatically, so A1 becomes A2, A3 and so on. If you want the reference to stay fixed, write it as $A$1 before copying.
  8. Test both outcomes. Change the input value so that it is above and below the threshold, and confirm the result flips as expected. This catches wrong operators and swapped results before the formula spreads across a real report.
  9. Stack a second condition with nesting. To grade three bands, place a second IF in the false position: =IF(A1>=80,"High",IF(A1>=50,"Medium","Low")). Excel reads the tests in order and stops at the first one that passes, so order matters. Put the most restrictive test first.
  10. Combine tests with AND or OR when two conditions must be checked. For both conditions to be true, use =IF(AND(A1>50,B1="Yes"),"Go","Stop"). For either condition to be true, use OR in the same place. Keep the comma after the closing bracket of AND or OR.
  11. Return a blank or a calculation instead of text. Two empty quotes "" return a blank cell, which is useful when you do not want an error to show. You can also return a sum, for example =IF(B1>0,B1*0.1,0) to calculate a commission only when sales are positive.
  12. Tidy up and lock the sheet when it works. Press Ctrl+Enter (Cmd+Enter on Mac) to fill the selected range in one go. Once the results are correct, consider copying the output column and using Paste Special to paste values only, so later edits to the source data do not silently change the figures.

Common Mistakes

  • Leaving out the quotes around text. =IF(A1>50,Pass,Fail) produces an error because Excel reads Pass as a name. Use "Pass".
  • Mixing up the true and false results. This is the most frequent error and shows up only when the test fails. Check both outcomes, not just the one you expected.
  • Using a comma as a decimal separator in the wrong region. If your system uses commas for decimals, Excel expects semicolons between arguments: =IF(A1>50;"Pass";"Fail"). Excel usually converts automatically when you paste, but typing by hand follows the regional setting.
  • Nesting too deeply. Very long chains of IFs are hard to read and easy to break. For three or more bands, look at the IFS function or a lookup table instead.
  • Comparing text to numbers. A number stored as text, for example "50" with a green triangle, will not compare as expected with a real number. Convert the column to numbers first.
  • Forgetting the closing bracket. Every IF needs its bracket closed. Excel will prompt, but nested formulas can hide the fault.

Tips

  • Use the function tooltip as a reminder of the argument order: test, true, false.
  • Keep thresholds in their own cells, such as a cell holding 50, and reference them. Changing a target later then means editing one cell, not every formula.
  • Use IFERROR around a calculation that might divide by zero, for example =IFERROR(A1/B1,"Check"), to show a friendly message instead of an error.
  • Break long formulas into helper columns one step at a time, confirm each, then combine them once the pieces work.
  • Name ranges on the Formulas tab if you test the same criteria repeatedly; the formula becomes far easier to read.

Troubleshooting

  • The cell shows the formula as text. The cell is formatted as Text, or the sheet is in Show Formulas mode. Change the format to General and re-enter the formula, or turn Show Formulas off on the Formulas tab.
  • #VALUE! error. One of the arguments is the wrong type, usually an unbracketed text value or a reference to a cell holding text where a number is expected.
  • #NAME? error. Excel does not recognise a word in the formula, most often unquoted text or a misspelt function name.
  • #N/A error. A referenced value cannot be found. Check that the comparison values match exactly, including spaces and letter case where the comparison is case-sensitive.
  • The result does not change when the input does. The formula may be referring to a fixed cell you did not intend. Check for dollar signs or test the reference by clicking the cell it points to.
  • If that did not work, click the cell and use the formula bar to step through the arguments slowly, deleting and retyping each one. If a copy of the formula behaves differently from the original, check whether the references moved as intended.

Frequently Asked Questions

Can IF return a blank cell?

Yes. Use two double quotes as the result, for example =IF(A1=0,"",A1), and the cell will look empty.

How many IFs can I nest?

Modern Excel allows a large number, but readability drops fast. Use IFS or a lookup table once you need more than three bands.

Does IF work with dates?

Yes, but compare against a date entered with the DATE function, such as DATE(2026,1,1), rather than text, because text dates may not compare correctly.

Is IF case-sensitive?

No. For a case-sensitive test, use EXACT inside the IF, for example =IF(EXACT(A1,"Yes"),1,0).

Can I use IF to check whether a cell is empty?

Yes. Compare to empty quotes, as in =IF(A1="","Missing",A1), to flag blanks.