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
- Check your data layout first
- Insert one level of subtotals
- Dialog options explained
- Add a second calculation to the same column
- Insert nested subtotals
- Collapse and expand the subtotals
- Remove subtotals
- Subtotals and filters
- The SUBTOTAL function behind it
- Sources
- More Word, Excel and PowerPoint guides
Quick answer: insert subtotals in Excel
| Step | Where |
|---|---|
| 1. Sort the column you want to group by | Data > Sort A to Z or Sort Z to A |
| 2. Open the command | Data > Outline group > Subtotal |
| 3. Fill in the dialog | At each change in, Use function, Add subtotal to |
| 4. Collapse or expand | Outline buttons 1, 2, 3 and the plus and minus symbols |
| 5. Undo it later | Data > 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.
- Click any cell in the range.
- 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.
- On the Data tab, in the Outline group, click Subtotal.
- In At each change in, pick the column to group by.
- In Use function, pick the calculation, such as Sum.
- Under Add subtotal to, tick each column you want subtotalled.
- Optional: tick Page break between groups, and set Summary below data as you prefer.
- Click OK.
Sorting first matters because Excel inserts a subtotal wherever the value in the grouping column changes.
Dialog options explained
| Option | What it does |
|---|---|
| At each change in | Chooses the column that decides where each subtotal appears |
| Use function | Chooses the summary calculation, such as Sum or Average |
| Add subtotal to | Chooses which columns receive a subtotal |
| Replace current subtotals | Overwrites existing subtotals when ticked; clear it to keep them |
| Page break between groups | Adds an automatic page break after each subtotal |
| Summary below data | Puts 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.
- Sort the columns you want to group by, outer column first.
- 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.
- Open Data > Subtotal again and set At each change in to the inner column such as Sport.
- 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
- Click any cell in the range that has subtotals.
- On the Data tab, in the Outline group, click Subtotal.
- 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 rows | Ignores hidden rows | Calculation |
|---|---|---|
| 1 | 101 | AVERAGE |
| 2 | 102 | COUNT |
| 3 | 103 | COUNTA |
| 4 | 104 | MAX |
| 5 | 105 | MIN |
| 6 | 106 | PRODUCT |
| 7 | 107 | STDEV |
| 8 | 108 | STDEVP |
| 9 | 109 | SUM |
| 10 | 110 | VAR |
| 11 | 111 | VARP |
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.
More Word, Excel and PowerPoint guides
- How To Insert And Remove Page Breaks In Excel (2026)
- How To Save Word And Excel Files To Your PC By Default (2026)
- How To Show The Formula Bar And Gridlines In Excel (2026)
- How To Fix Excel Arrow Keys Scrolling The Sheet (2026)
- How To Fix Excel Column Headings Showing Numbers (2026)
- Excel Error: There Isn't Enough Memory To Complete This Action