An IF-THEN formula in Excel is just the IF function: =IF(condition, value_if_true, value_if_false). You test a condition once, then tell Excel exactly what to show when the test passes and what to show when it fails. For example, =IF(A2>=60,"Pass","Fail") displays "Pass" when the value in A2 is 60 or higher and "Fail" otherwise. Write the condition first, then the true result, then the false result, separated by commas, and close the bracket. That single pattern handles most real spreadsheet decisions, and stacking or nesting IFs extends it to three, four, or more outcomes.
What You'll Need
- Excel on Windows, Mac, Excel for the web, or Excel for iPhone and Android. The IF function itself is identical everywhere; only the typing experience differs.
- A spreadsheet with at least one column of values to test, and a clear idea of the outcome you want for each case.
- Basic awareness of how Excel separates arguments: commas in most English-language regional settings, semicolons in many European and other locales. If your formulas show an error about commas, your region uses semicolons instead.
Step-by-Step
- Decide the test. Write the question down in plain language before touching Excel: "Is the value in B2 greater than 100?" That becomes
B2>100. Use>,<,>=,<=,=, or<>(not equal to) as the comparison operator. - Pick a cell for the result. Click an empty cell in the same row as your data, such as C2 if the value sits in B2. This keeps the formula easy to copy down later.
- Start the formula. Type
=IF(and Excel will show a tooltip listing the arguments: logical_test, value_if_true, value_if_false. The tooltip is useful while you learn, so leave it open for the first few attempts. - Enter the condition. Type your test, for instance
B2>100, then a comma. Text values need quotes around them:B2="Open"tests whether B2 contains exactly the word Open. - Enter the true result. Type the value you want when the test passes, such as
"Over budget". Excel displays that text literally because it is in quotes. - Enter the false result. Type the value for a failed test, such as
"Within budget". If you truly want nothing shown when the test fails, use""(two double quotes with nothing between them). - Close the bracket and press Enter. The full formula reads
=IF(B2>100,"Over budget","Within budget"). Excel checks the result against the cell and shows the appropriate value. - Copy it down the column. Select the cell, grab the small square handle in the bottom-right corner, and drag down. Relative references like B2 adjust to B3, B4 and so on automatically. Double-clicking the handle fills down to the last adjacent row, which is faster for long lists.
- Return a number instead of text when you need to calculate. Replace the text results with numbers or references:
=IF(B2>100,B2*0.1,0)adds a 10% bonus above the threshold and zero below it. Numbers work without quotes; text always needs them. - Add a second condition with nesting. To grade scores, use
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","F"))). Each new IF goes into the false-result slot of the previous one. Test the highest threshold first, because Excel stops at the first true condition. - Use AND or OR for two rules at once.
=IF(AND(B2>=50,C2="Paid"),"Approve","Hold")requires both conditions to be true. Swap AND for OR when either one alone should trigger the result. - Copy the result as values if formatting matters. Select the formula cells, press Ctrl+C (Cmd+C on Mac), then right-click and choose Paste Special > Values to replace formulas with their current results. This is useful before sorting or sending the file, but the formulas are then gone for good.
Common Mistakes
Forgetting quotes around text. =IF(A2>10,Yes,No) returns a #NAME? error because Excel treats Yes and No as undefined names. Write "Yes" and "No" instead.
Wrong comparison order when nesting. Testing B2>=70 before B2>=90 labels a 95 as a C, because the first true test wins. Always order thresholds from strictest to loosest.
Missing or extra parentheses. Every IF opens one bracket and each nested IF must close one. Excel usually offers to correct an unbalanced formula, but accept that prompt with care: it can shift where a bracket lands and change the logic silently.
Comparing text to numbers. A value stored as text (often imported data) will not match a numeric test. Select the column and use Data > Text to Columns, or multiply by 1 in a helper cell, to convert it.
Assuming blank cells behave as zero. An empty cell in a > test is treated as 0, so blanks can pass checks you did not intend. Guard with an IF that tests A2="" first.
Tips
Keep each formula readable by putting one nesting level per line; use Alt+Enter (Option+Return on Mac) to insert a line break inside the formula bar.
Use cell references for thresholds rather than hard-coded numbers, so one change updates every result. A threshold in F1 makes =IF(B2>$F$1,"Yes","No") easy to adjust; the dollar signs lock the reference when copying.
When a formula gets longer than three nested IFs, IFS is cleaner: =IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F"). IFS is available in Excel 2019, Microsoft 365, and current web and mobile versions, but not in Excel 2016 or older.
Name your results consistently. Mixing "Yes" with "YES" or trailing spaces in source cells causes silent mismatches, so trim text with TRIM where data is imported.
Troubleshooting
If you see #NAME?, check for unquoted text, a misspelled function, or a locale that expects semicolons instead of commas.
If you see #VALUE!, one argument is the wrong type, usually text where Excel expects a number. Inspect the compared cell with ISTEXT to confirm.
If the formula shows as text rather than calculating, the cell is formatted as Text. Change the format to General and re-enter the formula; reformatting alone does not recalculate it.
If every row returns the same answer, a reference is probably absolute when it should be relative. Remove the dollar signs or re-copy from the original cell.
If a nested formula gives odd results, click the cell and use Formulas > Evaluate Formula to step through each test and see exactly where the logic diverges. This is the fastest diagnostic for deep nesting.
If copying produces #REF!, the formula points to a deleted cell or a range that shifted. Undo, or rewrite the references.
Frequently Asked Questions
Can I use IF without a false result?
Yes. =IF(A2>10,"High") returns FALSE when the test fails. Supply "" as the third argument instead to show a blank.
How many IFs can I nest?
Modern Excel allows up to 64 nested levels, but formulas become hard to audit past three or four. IFS or a lookup table is usually the better choice.
Does IF work on text?
Yes, with exact matches in quotes. For partial matches use SEARCH or COUNTIF inside the test, for example =IF(COUNTIF(A2,"*urgent*")>0,"Flag","").
What is the difference between IF and IFS?
IF handles one test with a true and false branch. IFS handles multiple tests in a single function without nesting, but needs a current version of Excel.
Why does my IF result look wrong on mobile?
Excel for iPhone and Android supports IF fully. Check that typing auto-capitalisation or smart punctuation has not inserted curly quotes, which Excel reads as text characters rather than quote marks.