How to Perform Subtotal in Excel: Step-by-Step Guide
In this article
To perform a subtotal in Excel, first sort your data by the column you want to group on, then select the range and go to Data > Subtotal. Choose the column to group by, the function (SUM, COUNT, AVERAGE, etc.), and the column to subtotal. Excel inserts subtotal rows and a grand total. This works in Excel for Microsoft 365, Excel 2021, 2019, and 2016 on Windows and Mac; the exact labels can differ slightly by version and region.
What You'll Need
- Excel desktop app (Windows or Mac). The Subtotal feature is not available in Excel for the web or most mobile apps.
- A data range with a header row and no blank rows or columns inside the range.
- Data sorted by the column you want to group on (e.g., Region, Category, Month).
Step-by-Step
- Prepare your data. Make sure each column has a clear header in row 1. Remove any blank rows or columns inside the data range, because Excel may stop at the first blank when detecting the range. If you have a total row at the bottom, delete it for now; Subtotal will add its own grand total.
- Sort by the grouping column. Click any cell in the column you want to group by (for example, Region). On the Data tab, click Sort A to Z or Sort Z to A. Alternatively, use Sort and choose the column and order. Sorting is essential: Subtotal inserts a subtotal each time the value in the group column changes, so unsorted data produces many small, incorrect subtotals.
- Select the data range. Click any cell inside the data and press Ctrl+A (Windows) or Command+A (Mac) to select the current region, or drag to select the entire range including headers. Do not select the header row alone.
- Open the Subtotal dialog. Go to the Data tab and click Subtotal in the Outline group. (If you don't see it, make sure you are on the Data tab and that your selection is inside a data range.)
- Choose the group column. In the "At each change in" dropdown, select the column you sorted by (e.g., Region).
- Choose the function. In "Use function", pick Sum, Count, Average, Max, Min, Product, Count Numbers, StdDev, or Var. Sum is the most common for numeric totals.
- Choose the column(s) to subtotal. In "Add subtotal to", tick the column(s) you want calculated (e.g., Sales). Do not tick the group column itself unless you really want to count or sum it.
- Set options. Tick "Replace current subtotals" if you are redoing an existing subtotal. Tick "Page break between groups" if you plan to print each group on a new page. Tick "Summary below data" to place the grand total at the bottom (recommended).
- Click OK. Excel inserts a subtotal row after each group and a grand total at the bottom, and adds outline buttons (1, 2, 3) on the left side so you can collapse or expand groups.
- Verify and format. Check a few subtotals manually. Use the outline buttons to collapse to level 2 (subtotals only) or level 1 (grand total only). Apply bold or a fill color to subtotal rows if you want them to stand out.
To remove subtotals later, select the range, open Data > Subtotal, and click Remove All. This removes the subtotal rows but leaves your original data intact.
Common Mistakes
- Not sorting first. This is the most common error. Subtotal groups by changes in value, so unsorted data creates a subtotal every time the value changes, even if the same value appears again later.
- Leaving blank rows or columns. Excel may treat the blank as the end of the range, so part of your data is ignored. Delete or fill blanks before starting.
- Including a pre-existing total row. If your data already has a total row, Subtotal may double-count it. Remove manual totals first.
- Subtotaling the wrong column. Ticking the group column (e.g., Region) in "Add subtotal to" produces a count of text entries instead of a sum of sales. Only tick numeric columns you want calculated.
- Using Subtotal on a formatted Excel Table. The Subtotal feature works best on a normal range. If your data is an Excel Table (created with Insert > Table), convert it to a range first (Table Design > Convert to Range) or use a PivotTable instead.
- Forgetting that Subtotal is not dynamic. If you change the data after inserting subtotals, the subtotal rows do not update automatically. Re-run Subtotal with "Replace current subtotals" ticked, or use a PivotTable for a refreshable summary.
Tips
- Use the outline buttons (1, 2, 3) to quickly show only subtotals or only the grand total. This is handy for printing a summary.
- If you need multiple levels of grouping (e.g., Region then Product), run Subtotal once for the outer group, then run it again for the inner group with "Replace current subtotals" unticked. Excel nests the subtotals.
- For a summary that updates when data changes, consider a PivotTable (Insert > PivotTable) instead of Subtotal. PivotTables are refreshable and handle large datasets well.
- To subtotal only visible rows (e.g., after filtering), use the SUBTOTAL function in a formula instead of the Data > Subtotal feature. The function ignores rows hidden by filters when you use function numbers 101–111.
- Keep a backup copy of your sheet before running Subtotal the first time, so you can compare results or revert if needed.
Troubleshooting
- Subtotal is greyed out. Make sure you have selected a cell inside a data range, not a blank cell or a chart. Also confirm you are using the desktop app; the feature is not in Excel for the web.
- Subtotals appear after every row. Your data is not sorted by the group column. Sort the column first, then re-run Subtotal with "Replace current subtotals" ticked.
- Some rows are missing from the subtotal. Check for blank rows or columns inside the range. Select the entire range manually (including all rows) before opening the Subtotal dialog.
- Grand total is wrong. You may have included a manual total row in the range, or ticked the wrong column. Remove manual totals, then re-run Subtotal.
- Subtotal rows do not update after editing data. This is expected. Re-run Subtotal with "Replace current subtotals" ticked, or switch to a PivotTable for automatic refresh.
- Outline buttons are missing. Go to File > Options > Advanced (Windows) or Excel > Preferences (Mac) and ensure "Show outline symbols if an outline is applied" is ticked. On Mac, check the View tab for outline settings.
Frequently Asked Questions
Can I subtotal more than one column at a time?
Yes. In the Subtotal dialog, tick multiple columns under "Add subtotal to". Excel will calculate each selected column for every group.
Does Subtotal work on filtered data?
The Data > Subtotal feature inserts rows into the sheet and does not respect filters in the same way as the SUBTOTAL function. For filtered data, use the SUBTOTAL function in a formula (e.g., =SUBTOTAL(109, range)) which ignores hidden rows.
What is the difference between Subtotal and SUM?
SUM adds a range of cells. Subtotal is a feature that automatically inserts SUM (or another function) rows for each group in sorted data, plus a grand total. The SUBTOTAL function is a formula that can ignore filtered or hidden rows.
Can I use Subtotal in Excel for the web or mobile?
No, the Data > Subtotal feature is not available in Excel for the web or the mobile apps. You can use the SUBTOTAL function in a formula instead, or open the file in the desktop app.
How do I remove subtotals?
Select the range, go to Data > Subtotal, and click Remove All. This deletes the subtotal rows and restores your original data layout.
Why does Subtotal add a row after every single row?
Because the data is not sorted by the group column. Sort the column first, then re-run Subtotal with "Replace current subtotals" ticked.