How To Insert Subtotals In Excel (2026)

The Subtotal command adds subtotal rows and a grand total to a list in a few clicks.

It also builds an outline, so you can collapse the list down to just the totals.

This guide covers one level of subtotals, nested levels, the outline buttons, removing subtotals and the SUBTOTAL function.

Table of Contents

Quick answer: insert subtotals in Excel

StepWhere
1. Sort the column you want to group byData > Sort A to Z or Sort Z to A
2. Open the commandData > Outline group > Subtotal
3. Fill in the dialogAt each change in, Use function, Add subtotal to
4. Collapse or expandOutline buttons 1, 2, 3 and the plus and minus symbols
5. Undo it laterData > Subtotal > Remove All

Check your data layout first

  • Each column needs a label in the first row.
  • Each column should hold the same kind of data.
  • The range cannot contain blank rows or blank columns.

Subtotal is greyed out inside an Excel table.

To use it, convert the table to a normal range, which removes all table features except the formatting, or build a PivotTable instead.

For a PivotTable route, see our guide to creating a PivotTable in Excel.

Insert one level of subtotals

The example in Microsoft’s guide totals Sales every time the Sport column changes.

  1. Click any cell in the range.
  2. Select the column you want to group by, then on the Data tab, in the Sort & Filter group, click Sort A to Z or Sort Z to A.
  3. On the Data tab, in the Outline group, click Subtotal.
  4. In At each change in, pick the column to group by.
  5. In Use function, pick the calculation, such as Sum.
  6. Under Add subtotal to, tick each column you want subtotalled.
  7. Optional: tick Page break between groups, and set Summary below data as you prefer.
  8. Click OK.

Sorting first matters because Excel inserts a subtotal wherever the value in the grouping column changes.

Dialog options explained

OptionWhat it does
At each change inChooses the column that decides where each subtotal appears
Use functionChooses the summary calculation, such as Sum or Average
Add subtotal toChooses which columns receive a subtotal
Replace current subtotalsOverwrites existing subtotals when ticked; clear it to keep them
Page break between groupsAdds an automatic page break after each subtotal
Summary below dataPuts the summary row below the details; clear it to put the row above

Add a second calculation to the same column

You can apply more than one summary function to the same column.

Repeat the Subtotal steps with a different function, and clear Replace current subtotals so the first set stays in place.

Grand totals use the detail rows, not the subtotal rows, so a grand total with Average averages every detail row.

Insert nested subtotals

Microsoft’s example totals Sales for each Region and then for each Sport inside each Region.

  1. Sort the columns you want to group by, outer column first.
  2. Open Data > Subtotal, set At each change in to the outer column such as Region, pick the function and the value columns, and click OK.
  3. Open Data > Subtotal again and set At each change in to the inner column such as Sport.
  4. Clear Replace current subtotals so the outer subtotals remain, then click OK.

For more levels, repeat the inner step and work from the outermost level inward.

Collapse and expand the subtotals

Click the level symbols 1, 2 and 3 beside the row numbers to show only the grand total, the subtotals, or all the detail.

Use the plus and minus symbols to open or close the detail rows for one subtotal.

Press Ctrl+8 to show or hide the outline symbols.

To expand or collapse grouped rows with the mouse, hover over them, hold Shift and scroll down to expand or up to collapse.

If rows are hidden by hand, our guide to hiding and unhiding rows in Excel shows how to bring them back.

Remove subtotals

  1. Click any cell in the range that has subtotals.
  2. On the Data tab, in the Outline group, click Subtotal.
  3. In the Subtotal dialog box, click Remove All.

Subtotals and filters

If you filter a list that contains subtotals, some subtotals may seem to disappear.

Clear all filters to show them again.

For filtering basics, see how to sort and filter data in Excel.

The SUBTOTAL function behind it

Each subtotal row is a SUBTOTAL formula, and you can edit it after Excel creates it.

The syntax is SUBTOTAL(function_num, ref1, [ref2], …), with up to 254 references.

The first argument must be a number from 1 to 11 or 101 to 111.

Includes manually hidden rowsIgnores hidden rowsCalculation
1101AVERAGE
2102COUNT
3103COUNTA
4104MAX
5105MIN
6106PRODUCT
7107STDEV
8108STDEVP
9109SUM
10110VAR
11111VARP

Rows removed by a filter are always ignored, whichever number you use.

Microsoft’s example enters 120, 10, 150 and 23 in A2:A5, where =SUBTOTAL(9,A2:A5) returns 303 and =SUBTOTAL(1,A2:A5) returns 75.75.

Subtotals nested inside the references are ignored so nothing is counted twice, and a 3-D reference returns #VALUE!.

For conditional totals, see SUMIF and COUNTIF in Excel.

Sources

Microsoft Support: Insert subtotals in a list of data in a worksheet, SUBTOTAL function and Keyboard shortcuts in Excel.

Leave a Reply

Your email address will not be published. Required fields are marked *