Use nested functions in an Excel formula

Applies To
Excel for Microsoft 365 Excel 2024 Excel 2021

Using a function as one of the arguments in a formula that uses a function is called nesting. This function is a nested function. For example, by nesting the AVERAGE and SUM functions in the arguments of the IF function, the following formula sums a set of numbers (G2:G5) only if the average of another set of numbers (F2:F5) is greater than 50. Otherwise, it returns 0.

Nested functions

The AVERAGE and SUM functions are nested within the IF function.

You can nest up to 64 levels of functions in a formula.

  1. Select the cell where you want to enter the formula.

  2. To start the formula with the function, select Insert Function Screenshot of Insert Function button. on the formula bar Button image .
    Excel inserts the equal sign (⁠=⁠) for you.

  3. In the Or select a category box, select All.
    If you're familiar with the function categories, you can also select a category.
    If you're not sure which function to use, type a question that describes what you want to do in the Search for a function box (for example, "add numbers" returns the DSUM, IMSUM, and SUM functions).

  4. To enter another function as an argument, enter the function in the argument box that you want.
    The parts of the formula displayed in the Function Arguments dialog box reflect the function that you selected in the previous step.
    If you selected IF, the Function arguments dialog box displays the arguments for the IF function. To nest another function, enter it into the argument box. For example, you could enter SUM(G2:G5) in the Value_if_true box of the IF function.

  5. Enter any additional arguments needed to complete your formula.
    Instead of typing cell references, you can also select the cells that you want to reference. Select the up arrow to minimize the dialog box, select the cells you want to reference, and then select the down arrow to expand the dialog box again.

    Tip

    For more information about the function and its arguments, select Help on this function.

  6. After you complete the arguments for the formula, select OK.

Examples

The following example shows how to use nested IF functions to assign a letter grade to a numeric test score.

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. In the web example, before you paste, select Paste Special > Values only. If needed, adjust the column widths to see all the data.

Score    
45
90
78
Formula Description Result
'=IF(A2>89,"A",IF(A2>79,"B", IF(A2>69,"C",IF(A2>59,"D","F")))) Uses nested IF conditions to assign a letter grade to the score in cell A2. =IF(A2>89,"A",IF(A2>79,"B",IF(A2>69,"C",IF(A2>59,"D","F"))))
'=IF(A3>89,"A",IF(A3>79,"B", IF(A3>69,"C",IF(A3>59,"D","F")))) Uses nested IF conditions to assign a letter grade to the score in cell A3. =IF(A3>89,"A",IF(A3>79,"B",IF(A3>69,"C",IF(A3>59,"D","F"))))
'=IF(A4>89,"A",IF(A4>79,"B", IF(A4>69,"C",IF(A4>59,"D","F")))) Uses nested IF conditions to assign a letter grade to the score in cell A4. =IF(A4>89,"A",IF(A4>79,"B",IF(A4>69,"C",IF(A4>59,"D","F"))))

Tip

Need more help?

You can always ask an expert in the Excel Tech Community or get support in Communities.

See also

IF function