How to Edit Subtotals in Excel: Step-by-Step
In this article
To edit subtotals in Excel, you first need to understand how they were created. If the subtotals came from the Data > Subtotal command, the fastest way to change them is to remove the existing subtotals and reapply the command with your new settings. If they are individual SUBTOTAL formulas, you can edit the formula arguments directly, or use Find and Replace to change the function number across many cells at once. If they are part of a PivotTable, you edit the field settings instead. The steps below cover each case, starting with the most common one.
What You'll Need
- Excel for Windows, Mac, or the web (menu labels can differ slightly by version, device, and region).
- A worksheet that already contains subtotals, or data you want to subtotal.
- Your data sorted the way you want it grouped (for example, by Region, then by Product). The Data > Subtotal command groups rows by changes in a column, so the sort order matters.
- No blank rows inside the data range, and a single header row at the top.
Step-by-Step
Case 1: Subtotals created with Data > Subtotal
- Select any cell inside your data range. If your data is formatted as an Excel Table, convert it to a normal range first (Table Design > Convert to Range), because the Subtotal command is greyed out for Tables.
- Go to the Data tab and click Subtotal. If subtotals already exist, Excel asks whether to replace the current subtotals. Click OK to replace them, or click Remove All to strip them out completely.
- In the Subtotal dialog, set At each change in to the column that defines your groups (for example, Region).
- Set Use function to the calculation you want: Sum, Count, Average, Max, Min, Product, Count Numbers, StdDev, or Var.
- Under Add subtotal to, tick the numeric columns you want totalled. Untick any you do not.
- Leave Replace current subtotals ticked so Excel does not stack a second layer of subtotals on top of the first.
- Optionally tick Page break between groups and Summary below data, then click OK. The new subtotals replace the old ones.
If you only want to change one subtotal value, do not type over it. Subtotal rows are generated by Excel and typing into them breaks the link to the detail rows. Instead, edit the underlying data and Excel recalculates the subtotal automatically.
Case 2: Individual SUBTOTAL formulas
- Click the cell containing the SUBTOTAL formula and look at the formula bar. It reads something like
=SUBTOTAL(9,D2:D10), where 9 means SUM. - To change the calculation, replace the first argument with the function number you want: 1 = AVERAGE, 2 = COUNT, 3 = COUNTA, 4 = MAX, 5 = MIN, 6 = PRODUCT, 7 = STDEV.S, 8 = STDEV.P, 9 = SUM, 10 = VAR.S, 11 = VAR.P. Add 100 to any of these (for example 109) to ignore manually hidden rows.
- To change the range, edit the second argument, for example from D2:D10 to D2:D20. Press Enter.
- To change many formulas at once, select the cells, press Ctrl+H (Cmd+H on Mac), enter the old function number and range pattern in Find what, enter the new one in Replace with, and click Replace All. Work on a copy first, because Replace All cannot be undone in one step across a whole sheet.
- Copy the edited formula down to the other subtotal rows if needed.
Case 3: Subtotals inside a PivotTable
- Click anywhere in the PivotTable.
- On the PivotTable Analyze tab (called Analyze on some versions), click Field Settings, or right-click a field in the Rows area and choose Field Settings.
- Open the Subtotals tab and choose Automatic, Custom (then pick a function such as Sum, Count, or Average), or None.
- Click OK. To change the number format of the subtotal, use the Layout & Print tab or the Value Field Settings dialog for the value field.
Common Mistakes
- Typing over a generated subtotal row. Data > Subtotal rows are formula-driven; manual edits get overwritten the next time the subtotals are refreshed.
- Forgetting to sort first. The Subtotal command groups by changes in a column, so unsorted data produces repeated subtotals for the same group.
- Leaving Replace current subtotals unticked. This nests a second set of subtotals and doubles your totals.
- Using SUM instead of SUBTOTAL. A plain SUM includes rows hidden by a filter, so filtered totals look wrong. SUBTOTAL with function 9 ignores filtered-out rows.
- Subtotalling an Excel Table. The command is unavailable until you convert the Table to a range.
- Editing a PivotTable subtotal as if it were a normal cell. PivotTable values are read-only; change the field settings instead.
Tips
- Use the outline buttons (1, 2, 3) at the left of the sheet to collapse and expand groups after editing subtotals.
- If you need subtotals at two levels, run Data > Subtotal twice: once for the outer group and once for the inner group, unticking Replace current subtotals the second time.
- For recurring reports, a PivotTable is usually easier to edit than Data > Subtotal, because you can change fields without rebuilding the layout.
- Keep a backup copy before using Find and Replace across formulas.
Troubleshooting
- Subtotal is greyed out: your data is probably an Excel Table, or no cell inside the range is selected. Convert the Table to a range and select a data cell.
- Totals do not update after editing data: check that calculation is set to Automatic (Formulas > Calculation Options > Automatic).
- Duplicate subtotal rows appear: remove all subtotals (Data > Subtotal > Remove All) and reapply once with Replace current subtotals ticked.
- Filtered totals look too high: replace SUM with SUBTOTAL(9, range), which ignores rows hidden by a filter.
- PivotTable subtotal option is missing: subtotals only appear when the Rows area has more than one field, or when the outer field has subtotals enabled in Field Settings.
- Formula returns #VALUE!: the range argument probably includes text or an error cell; check the referenced cells.
Frequently Asked Questions
Can I edit a subtotal value directly?
No. Subtotal rows generated by Data > Subtotal and PivotTable subtotals are calculated by Excel. Edit the source data or the field settings instead.
How do I remove subtotals without deleting my data?
Select a cell in the range, go to Data > Subtotal, and click Remove All. This removes only the subtotal rows and outline, not your detail rows.
What is the difference between SUM and SUBTOTAL?
SUM adds every cell in the range, including rows hidden by a filter. SUBTOTAL with function number 9 ignores filtered-out rows, which is why it is used for subtotals.
Why does my subtotal show the wrong group?
The data is probably not sorted by the group column. Sort the range first, then reapply Data > Subtotal.
Can I change the subtotal function for all groups at once?
Yes. Reopen Data > Subtotal, choose a different function under Use function, keep Replace current subtotals ticked, and click OK.
Do subtotals work in Excel for the web?
The Data > Subtotal command is available in Excel for the web, but some advanced options and PivotTable field settings may differ from the desktop app. Labels can also vary by version and region.