The THEN function in Excel is a bit of a myth: Excel has no standalone THEN function. What people mean by "then" is really the IF function, whose logic reads "if this is true, then do that." In practice you write a test, a value to return when the test passes, and a value to return when it fails, all inside one IF formula. Excel then handles the "then" part automatically. This guide walks through writing IF formulas correctly, chaining several conditions, and fixing the errors that most often break them.
Most people build these formulas in the standard Windows, Mac, or web version of Excel. Google Sheets, Numbers, and LibreOffice use the same IF function, so the same ideas transfer, though exact menu labels can differ slightly by version, device, or region.
What You'll Need
- A spreadsheet with at least data to test, for example a column of scores, dates, or amounts.
- A cell to hold the formula, separate from the data column.
- Basic familiarity with cell references such as A2 and B2.
- Excel's IF function, which is part of every current version; no add-in or subscription tier is required.
- If you want (not needed to start): a second column for the comparison value, so your thresholds live in cells rather than being typed into the formula.
Step-by-Step
- Decide the test. Before typing anything, write the question in plain words. For example: "Is the score in A2 at least 70?" That becomes the first argument of the formula, called the logical test.
- Click the cell for the result and press = or click the Insert Function button next to the formula bar. The cell where you place the formula should be empty so nothing is overwritten.
- Type the function name and an opening parenthesis. Type
=IF(and Excel shows a tooltip listing the arguments in order. The tooltip is the fastest way to confirm the order: test, value if true, value if false. - Enter the logical test. Type
A2>=70. Use two-letter comparison operators:=for equals (which is==in Google Sheets but plain=in Excel),<=,>=,<>for not equal. Put text criteria in double quotes, for exampleB2="Yes". - Add a comma, then the value if true. Type
"Pass"with the quotes. Numbers do not need quotes; text does, otherwise Excel shows a #NAME? error. Quotes hide the quotes themselves from the result. - Add a comma, then the value if false. Type
"Fail"and close the parenthesis. The complete formula is=IF(A2>=70,"Pass","Fail"). Press Enter. The cell now shows Pass or Fail based on the score. - Copy the formula down the column. Drag the small fill handle at the bottom-right corner of the cell down, or select the range and use Ctrl+D on Windows or Command+D on Mac. Relative references such as A2 shift automatically, so each row tests its own value.
- Check the blank rows. An empty cell counts as zero, so a blank A2 can show Fail. Wrap the formula to catch blanks:
=IF(A2="","",IF(A2>=70,"Pass","Fail")). The empty string in quotes returns a blank result instead of an error.
To give the result more than two states, add a nested IF inside the value-if-false slot. For a simple grading scale:
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F")))
Excel reads nested IFs left to right and stops at the first test that passes, so order the thresholds from highest to lowest. Each extra IF needs its own pair of parentheses, and the closing parentheses must match the openings. For Excel 2019 and later and for Microsoft 365, the IFS function is cleaner:
=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"F")
In IFS, the pairs are test then result, and the final TRUE acts as the catch-all. IFS does not exist in older versions, where you keep using nested IF.
Common Mistakes
- Text without quotes.
Passwithout quotation marks is read as a cell reference or name and returns an error. Use"Pass". - Wrong comparison direction. Writing
A2=<70instead ofA2<=70triggers a syntax error. The operator comes before the number. - Numbers stored as text. If the data was imported, values may look numeric but behave as text, and every test returns the false result. Check with the ISTEXT function or look for the green triangle warning in the corner of the cell.
- Going from low to high in nested IFs. If the first test is
A2>=70and the second isA2>=90, a score of 95 matches the first test and gets the low grade. Sort thresholds from highest to lowest. - Forgetting the false value. Leaving that slot empty returns FALSE to the cell. Type a value or an empty string if you want a blank.
- Forgotten parentheses. Every
IF(needs one closing bracket at the end of its part. Excel usually points to the missing one when it refuses the formula.
Tips
- Use cell references for thresholds instead of hard-coded numbers, for example
=IF(A2>=$F$1,"Pass","Fail"). Change F1 and every formula updates. A dollar sign before the column and row locks the reference when you fill down. - Combine tests with AND and OR, for example
=IF(AND(A2>=70,B2="Yes"),"Pass","Fail"), which only passes when both conditions are true. - Name the function properly if you search for it: there is no THEN function, so look for IF on Microsoft's support pages and in tutorials.
- Use Formulas > Evaluate Formula (on the Formulas tab) to step through a confusing formula one argument at a time. This is the fastest way to see exactly which test fails.
- If the result needs conditional formatting, apply it to the result column and use a text rule such as "equal to Pass" rather than colouring cells by hand.
Troubleshooting
If that did not work, work through these in order:
- Look at the error code. #NAME? almost always means text without quotes. #VALUE! means a test is comparing mismatched types. #N/A usually means a lookup inside the formula failed.
- Select the cell and check the parentheses with Formulas > Evaluate Formula or by clicking a bracket in the formula bar to highlight its pair.
- Test one condition alone: type
=A2>=70in a spare cell. It should return TRUE or FALSE. If it returns text, the data is stored as text. - Convert suspect numbers back to numbers. Check for leading apostrophes or use Text to Columns on the data range, which often converts text numbers to real ones.
- If copied formulas behave oddly, check whether you used a relative reference where a locked one was needed, or the reverse.
Frequently Asked Questions
Does Excel have a THEN function?
No. Excel has no THEN function. The IF function does the job: it tests a condition and returns one value when true and another when false, which is the same idea as "if... then... else."
Can I use AND or OR inside IF?
Yes. Put AND or OR in the logical-test slot, for example =IF(OR(A2="Yes",B2="Yes"),"Include","Exclude"). AND needs all conditions true; OR needs only one.
How many IFs can I nest?
Current Excel versions allow up to 64 nested functions, but long chains are hard to read and maintain. Switch to IFS or a lookup table once you pass three or four levels.
Why does my IF show TRUE or FALSE instead of my text?
The value-if-true or value-if-false slot is missing, so Excel returns the test result itself. Add the intended values in quotes, or an empty string to show a blank.
Can I write the IF logic without the IF function?
For two results you can use =--(A2>=70) to get 1 or 0, or =(A2>=70)*1, and both are valid when you need a number rather than text. For anything more complex, IF or IFS is clearer.
Does the same formula work in Google Sheets?
IF, AND, OR, and IFS work the same way in Sheets. The one difference to remember is that Sheets also accepts == for equality, while Excel uses a single =.