An IF statement in Excel checks a condition and returns one result when that condition is true and another when it is false. That makes it useful for budgets, grades, status labels, yes-or-no checks, and other everyday worksheet decisions.
The basic formula works in current Excel desktop apps, Excel for Mac, and Excel for the web. Start with the two required parts and the optional third, then use Excel’s formula tools when you want more guidance.
Start with the basic IF formula
The standard pattern is =IF(logical_test, value_if_true, [value_if_false]). The logical test and the true value are required; the square brackets mean value_if_false is optional, though it is good practice to include it. The logical test is the question Excel checks, the true value is what Excel returns when the test passes, and the false value is what Excel returns when it does not.
For example, =IF(A2>B2,"Over Budget","OK") checks whether A2 is greater than B2. If it is, Excel shows Over Budget; if it is not, Excel shows OK.
Use quotation marks around text results, such as "Yes" or "No". Numbers do not need quotation marks.
If the formula does not work, use Insert Function so Excel guides you through Logical_test, Value_if_true, and Value_if_false.
Type an IF statement directly
Select the cell where you want the result to appear.
Type =IF( to begin the formula.
Enter the condition you want Excel to test, such as A2>B2.
Type a comma, then enter the result Excel should show when the condition is true.
Type another comma, then enter the result Excel should show when the condition is false.
Close the parenthesis and press Enter or Return.
Keep the formula simple at first, then copy it to the rest of the row or column after one result looks right.
Use Formula AutoComplete for faster entry
This helps you minimize typing and syntax errors and insert IF without typing the whole function name.
Select a blank cell.
Type = and the first letters of the function, such as IF.
When the Formula AutoComplete list appears, choose IF.
Press Tab or double-click IF to insert it.
Complete the arguments and press Enter or Return.
Turn on Formula AutoComplete on Mac
On Excel for Mac, open the Excel menu and choose Preferences. Go to Formulas and Lists, then open AutoComplete.
Select Show AutoComplete options for functions and named ranges. Excel then shows function suggestions while you type formulas.
Use Show options after typing to set how many letters you type before the suggestion menu appears. This setting is available in Excel for Microsoft 365 for Mac, Excel 2024 for Mac, and Excel 2021 for Mac.
Build IF with Insert Function
Select the destination cell.
Select Insert Function, select the fx button on the formula bar, or press Shift+F3.
In Search for a function, type IF and choose Go.
You can also open Or select a category and choose All.
Select IF, double-click it, and fill in Logical_test, Value_if_true, and Value_if_false.
Select OK to place the completed formula in the cell.
On Mac, Shift+F3 opens Formula Builder, where you can double-click IF, enter the same three parts, and press Done or Return.
Work in Excel for the web and mobile
In Excel for the web, open the workbook in your browser, select a cell, and type a formula beginning with =, such as =IF(A1>0,"Yes","No"). Formula AutoComplete appears below the cell as matches appear, and Enter finishes the formula.
On iPhone or iPad, tap the cell, then double-tap the cell or tap in the formula bar. Type the IF formula and confirm it.
On Android phones, tap the formula bar, type the formula, and tap the check mark. Android also has an fx button that starts a formula and opens the function library.
Add more than one condition
This fixes formulas that need to check several things before returning a result.
Put AND, OR, or NOT inside the logical_test part of IF.
Use AND when every condition must be true, as in =IF(AND(A2>0,B2>0),"OK","Check").
Use OR when any listed condition can be true.
Use NOT when Excel should reverse the result of a condition.
Finish the true and false results, then press Enter.
Choose IFS or SWITCH when IF gets messy
The most common cause of hard-to-fix IF formulas is too much logic packed into one nested formula.
You can place another IF inside the true or false part of a formula, such as =IF(D2>89,"A",IF(D2>79,"B",IF(D2>69,"C",IF(D2>59,"D","F")))). Match every parenthesis carefully and test the result before filling it down.
For many condition-and-result pairs, use IFS instead: =IFS(logical_test1, value_if_true1, logical_test2, value_if_true2), adding more logical_test and value_if_true pairs as needed. To add a default result, use TRUE as the final logical test and put the default value after it.
For exact-value matches, use SWITCH instead: =SWITCH(expression, value1, result1, default). Add a final default value so Excel has something to return when no match is found.
Copy edit and troubleshoot IF formulas
To copy an IF formula into adjacent cells, select the formula cell and the target cells, then use Home > Fill and choose Down, Right, Up, or Left. You can also press Ctrl+D to fill down, press Ctrl+R to fill right, or drag the fill handle and use Auto Fill Options.
To edit an existing IF formula, select the cell and double-click it, click in the formula bar, or press F2. Make the change and press Enter or Return.
To remove the formula, select the cell or range and press Delete. Excel removes the cell contents, including formulas, without removing formats, threaded comments, or notes.
When a nested IF formula gives the wrong answer, select the formula cell and go to Formulas > Formula Auditing > Evaluate Formula. Select Evaluate repeatedly to step through the calculation.
Fill a table column with one IF formula
Create an Excel table. Insert a new table column, then select one cell in that new column.
Type the IF formula, and press Enter. When your data is already in an Excel table, one IF formula can populate a calculated column. Excel automatically fills the formula into the rest of the column.
Use this when each row needs the same test, such as comparing actual spending with budget spending across the table.
Ask Copilot for an IF formula
Copilot can generate or explain an IF formula when Excel, your subscription, your license, and your organization settings include it.
Select the Copilot icon in the lower-right corner of Excel. Ask for the formula you need, such as Create an IF formula that returns Over Budget if C2 is greater than B2, otherwise Within Budget.
Review, edit, and verify the formula before using it. Excel can also show Copilot formula suggestions when you type = in a cell or enter example values that follow a pattern.
On Windows, manage those suggestions through File > Options > Copilot. In Excel for the web, use File > Options > Copilot Settings.
In the web suggestion card, use More options > Turn off Copilot suggestions for completing formulas when you want to disable that suggestion type.
Frequently Asked Questions
What are the three parts of an IF statement in Excel?
An IF statement uses a logical test, a value to return when the test is true, and a value to return when the test is false.
Does IF work in Excel for the web?
Yes. In Excel for the web, select a cell, type an IF formula that begins with =, use Formula AutoComplete as it appears, and press Enter.
Can I copy an IF formula down a column?
Yes. Select the formula cell and adjacent target cells, then use Home > Fill > Down, press Ctrl+D, or drag the fill handle.
When should I use IFS instead of IF?
Use IFS when you have several condition-and-result pairs. It is easier to read than stacking many nested IF statements.