To insert subtotals in Excel, first sort your data by the column you want to group on, then select your data range, go to the Data tab, click Subtotal, choose the group column and the function (such as Sum), and click OK. Excel inserts a subtotal row after each group and a grand total at the bottom. This guide walks through the exact steps, the mistakes that break the feature, and how to fix them.

What You'll Need

  • Excel for Windows, Mac, or Excel for the web (the Subtotal command is on the Data tab in all three; labels can differ slightly by version and region).
  • A data range with a header row in row 1 and no blank rows or columns inside the range.
  • Your data sorted by the column you want to group on — the Subtotal command groups rows only when identical values sit next to each other.

Step-by-Step

  1. Check the layout. Make sure row 1 contains headers, every column has a header, and there are no completely blank rows or columns within the data. Remove any existing subtotal rows first — the command will otherwise treat them as data and nest a second level.
  2. Sort by the group column. Click any cell in the column you want to group on (for example, Region or Category), then go to Data > Sort A to Z (or Z to A). If you need a secondary sort, use Data > Sort and add levels. Sorting is what makes the groups contiguous; without it, Excel creates a subtotal for every change in value, which produces many one-row groups.
  3. Select the data range. Click a single cell inside the data and press Ctrl+A (Windows) or Command+A (Mac) to select the current region, or drag to select the full range including headers. Do not select the entire sheet.
  4. Open the Subtotal dialog. Go to the Data tab and click Subtotal in the Outline group. (On Mac Excel, it is also on the Data tab.) The dialog opens with three dropdowns.
  5. Set “At each change in”. Choose the column you sorted by — this is the group column. Excel will insert a subtotal row each time the value in this column changes.
  6. Set “Use function”. Pick Sum for totals, or Count, Average, Max, Min, Product, Count Numbers, StdDev, or Var. Sum is the default and the most common choice.
  7. Set “Add subtotal to”. Tick the numeric columns you want totaled. Leave text columns unticked. If you tick the group column itself, Excel adds a count of that column, which is usually not what you want.
  8. Choose options. Leave “Replace current subtotals” ticked if you are redoing an existing subtotal setup. Tick “Summary below data” to place subtotal rows under each group (the usual choice); untick it to place them above. Tick “Page break between groups” only if you plan to print each group on its own page.
  9. Click OK. Excel inserts a subtotal row after each group and a Grand Total row at the bottom. Outline buttons (1, 2, 3) appear at the left; use them to collapse to totals only (2) or the grand total only (1).
  10. Verify and format. Check that the number of subtotal rows matches the number of distinct values in your group column. Apply bold or a fill color to subtotal rows so they stand out, and confirm the grand total equals the sum of the detail rows.

Common Mistakes

  • Skipping the sort. This is the number-one cause of “wrong” subtotals. If the group column is unsorted, Excel creates a subtotal at every change, so the same region can appear in several separate subtotal rows.
  • Leaving blank rows or columns in the range. Excel treats a blank row as the end of the data, so rows below it are ignored. Delete blank rows before starting.
  • Running Subtotal twice without replacing. If “Replace current subtotals” is unticked, Excel nests a second level of subtotals inside the first, producing confusing double counts. Tick it when re-running.
  • Selecting the wrong “Add subtotal to” columns. Ticking text columns or the group column itself adds counts instead of sums and can make the grand total look wrong.
  • Using subtotals on a formatted Excel Table. The Subtotal command is greyed out or behaves oddly inside a Table object. Convert the Table to a normal range first (Table Design > Convert to Range), or use a PivotTable instead.
  • Assuming subtotals update automatically. They do not recalculate when you edit detail rows unless you re-run the command or the cells are part of a formula-driven setup. Re-run Data > Subtotal after major edits.

Tips

  • Use the outline buttons (1, 2, 3) at the left edge to collapse groups for printing or reviewing totals without deleting detail rows.
  • For multi-level summaries (for example, subtotal by Region, then by Category), run Subtotal once for the outer group, then run it again with “Replace current subtotals” unticked for the inner group. Excel nests the levels.
  • If you need subtotals that refresh automatically when data changes, use a PivotTable (Insert > PivotTable) instead of the Subtotal command. PivotTables recalculate on refresh and handle unsorted data.
  • Format subtotal rows with a distinct fill or bold font before copying the sheet, so readers can tell totals from detail.
  • Keep a backup copy of the sheet before running Subtotal the first time; undoing a multi-level subtotal setup can take several Ctrl+Z presses.

Troubleshooting

  • Subtotal is greyed out. The range is likely inside an Excel Table, or no cell inside the data is selected. Click a cell in the data, convert the Table to a range if needed, and try again.
  • Subtotals appear after every row. The group column is not sorted, or every value is unique. Sort the column first, then re-run Subtotal with “Replace current subtotals” ticked.
  • Grand total does not match the sum of detail rows. Check for hidden rows, filtered rows, or a second nested subtotal level. Clear all subtotals (Data > Subtotal > Remove All) and start again.
  • Some rows are missing from the totals. A blank row or blank cell in the group column split the range. Fill or delete blanks, then re-run.
  • Subtotal rows appear in the wrong place. Check the “Summary below data” option — untick it to place subtotals above each group.
  • Numbers do not add up after editing. Subtotals are static values. Re-run Data > Subtotal, or switch to a PivotTable for automatic refresh.

Frequently Asked Questions

Can I insert subtotals without sorting?

Not reliably. The Subtotal command groups only adjacent identical values, so unsorted data produces a subtotal at every change. Sort the group column first, or use a PivotTable, which does not require sorting.

How do I remove subtotals?

Select a cell in the data, go to Data > Subtotal, and click Remove All. This deletes every subtotal row created by the command and leaves the detail rows intact.

Why is the Subtotal button greyed out?

Usually because the data is formatted as an Excel Table or no cell inside the range is selected. Convert the Table to a normal range (Table Design > Convert to Range) and select a cell in the data.

Do subtotals update when I change the data?

No. Subtotal rows are static. After editing detail rows, re-run Data > Subtotal with “Replace current subtotals” ticked, or use a PivotTable for automatic recalculation.

Can I have two levels of subtotals?

Yes. Run Subtotal once for the outer group, then run it again for the inner group with “Replace current subtotals” unticked. Excel nests the levels and the outline buttons let you collapse each one.

What is the difference between Subtotal and a PivotTable?

Subtotal inserts static summary rows into your existing sheet and requires sorted data. A PivotTable is a separate, refreshable summary object that handles unsorted data and multiple groupings — better for data that changes often.