Smart Systems for Home

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

How to Write IF Statements in Excel: Step-by-Step Guide

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

An IF statement in Excel tests a condition and returns one value if the condition is true and another if it is false. The basic syntax is =IF(logical_test, value_if_true, value_if_false). For example, =IF(A1>10,"High","Low") returns "High" when A1 is greater than 10 and "Low" otherwise. You need only Excel itself (any recent version, including Excel for Microsoft 365, Excel 2021, Excel 2019, and Excel for Mac) and a worksheet with data to test. The steps below apply to the desktop versions; the mobile apps accept the same formulas but are harder to type, and menu labels can differ slightly by version, device, and region.

What You'll Need

  • Excel for Windows, Mac, or the web (Microsoft 365, Excel 2021, 2019, or 2016).
  • A worksheet with at least one cell containing a value or formula to test.
  • Basic familiarity with cell references such as A1 and ranges such as A1:A10.

Step-by-Step

  1. Pick the cell for the result. Click an empty cell where you want the IF result to appear, for example B1 next to a value in A1.
  2. Start the formula. Type =IF( — the equals sign tells Excel this is a formula, and the opening parenthesis starts the function.
  3. Write the logical test. Type a comparison such as A1>10, A1="Yes", or ISBLANK(A1). Use =, <> (not equal), >, <, >=, or <=. Text values must be in double quotes.
  4. Add a comma and the true result. Type ,"High" (or a number, a cell reference, or another formula). The comma separates arguments.
  5. Add a comma and the false result. Type ,"Low", then close the parenthesis with ). The full formula is =IF(A1>10,"High","Low").
  6. Press Enter. Excel calculates the result. If you see a green triangle in the corner of the cell, hover over it to read the warning.
  7. Copy the formula down. Drag the fill handle (the small square at the bottom-right of the cell) down the column. Relative references such as A1 adjust to A2, A3, and so on; use $A$1 if you want the reference to stay fixed.
  8. Nest IFs for more than two outcomes. Put a second IF in the value_if_false position: =IF(A1>90,"A",IF(A1>80,"B",IF(A1>70,"C","F"))). Excel allows up to 64 nested IFs, but readability drops fast beyond two or three.
  9. Use AND or OR inside the test. Combine conditions with AND(A1>10,B1<5) or OR(A1="Yes",B1="Yes") as the logical_test argument.
  10. Consider IFS for many conditions. In Excel 2019 and later, =IFS(A1>90,"A",A1>80,"B",A1>70,"C",TRUE,"F") reads more cleanly than nested IFs. The final TRUE,"F" pair acts as the default.

Common Mistakes

  • Forgetting the equals sign at the start, so Excel treats the entry as text.
  • Omitting quotes around text values (A1=Yes instead of A1="Yes").
  • Using the wrong number of arguments — IF needs exactly three, separated by commas.
  • Mismatched parentheses in nested formulas; Excel will usually offer to fix them, but check the result.
  • Comparing text to numbers (for example, a number stored as text) and getting an unexpected result.
  • Using = instead of <> when you mean "not equal".

Tips

  • Build the formula in the formula bar so you can see the whole thing; press F2 to edit in place.
  • Use the Formula AutoComplete list that appears as you type function names.
  • Keep nested IFs to three levels or fewer; switch to IFS, a lookup table with VLOOKUP or XLOOKUP, or a helper column.
  • Return an empty string "" instead of 0 when you want a blank-looking result.
  • Test edge cases: exactly equal to the threshold, blank cells, and text in a numeric column.

Troubleshooting

  • #VALUE! error: one of the arguments is the wrong type, often text compared to a number. Check for stray spaces or numbers stored as text.
  • #NAME? error: a function name or text value is misspelled, or quotes are missing around text.
  • Formula shows as text: the cell is formatted as Text, or the entry is missing the leading equals sign. Change the format to General and re-enter.
  • Wrong result after copying: a relative reference shifted when you did not want it to. Lock it with dollar signs ($A$1).
  • Too many arguments error: an extra comma or a missing closing parenthesis. Count the commas — an IF has two.
  • Circular reference warning: the formula refers to its own cell. Move the formula or change the reference.

Frequently Asked Questions

Can I use IF with text instead of numbers?

Yes. Put the text in double quotes, for example =IF(A1="Paid","Done","Pending"). Text comparisons are not case-sensitive in Excel.

How many IF statements can I nest?

Excel allows up to 64 nested IF functions, but anything beyond two or three becomes hard to read and audit. Use IFS or a lookup table instead.

What is the difference between IF and IFS?

IF takes one condition and two outcomes. IFS takes pairs of condition and result and returns the first match, which is cleaner for multiple outcomes. IFS is available in Excel 2019 and later.

Can IF return a blank cell?

Yes. Use "" as the result, for example =IF(A1="","",A1*2). The cell looks empty but still contains a formula.

Why does my IF formula return 0 instead of blank?

Excel treats an empty result as 0 unless you specify "". Change the value_if_false argument to "".

Does IF work in Excel for the web and mobile?

Yes, the same syntax works in Excel for the web, Excel for iPhone, and Excel for Android. Typing long nested formulas is easier on a desktop or tablet keyboard.