Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Subtotal Button: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The Subtotal button in Excel inserts a formula that groups and summarizes rows in one click. To use it, first sort your data by the column you want to group on, then select any cell in the list and go to Data > Subtotal. That is the shortest working path. The button lives on the Data tab in the Outline group, and it opens a dialog where you choose the grouping column, the function (SUM, COUNT, AVERAGE, and so on), and which columns to add the subtotal to. The result is a set of subtotal rows inserted between groups, plus a grand total at the bottom, and outline buttons on the left so you can collapse or expand each group.

What You'll Need

  • Excel for Windows or Mac desktop (the Subtotal button is not available in Excel for the web; the web version can open and show existing subtotals but cannot insert new ones).
  • A data list with a single header row and no blank rows or blank columns inside the data range.
  • At least one column you can group by, such as a category, region, or department name.
  • Your data sorted by that grouping column before you click Subtotal. If it is not sorted, Excel inserts a subtotal after each change in value, which produces many small subtotals instead of one per group.

Step-by-Step

  1. Make sure the data is clean. Each column should have a header in row 1, and there should be no blank rows or fully blank columns inside the list. If there are, select the data range manually in the next step instead of letting Excel guess.
  2. Sort by the grouping column. Click any cell in the column you want to group by (for example, Region), then go to Data > Sort A to Z or Sort Z to A. Sorting groups identical values together, which is what the Subtotal feature relies on. If you skip this, you will get a subtotal every time the value changes, even if the same value appears again later.
  3. Select a cell inside the data. Click any single cell within the list. Excel will detect the surrounding range automatically. If the range is wrong, select the entire range including headers before continuing.
  4. Open the Subtotal dialog. Go to Data > Subtotal. The button is in the Outline group on the right side of the ribbon. Menu labels can differ slightly by Excel version, device, and region, but the button is in the same place on the desktop app.
  5. Choose the grouping column. In the At each change in dropdown, pick the column you sorted by. This is the column that defines each group.
  6. Choose the function. In the Use function dropdown, pick SUM for totals, COUNT for counts, AVERAGE for averages, MAX or MIN for extremes, or PRODUCT for multiplication. SUM is the default.
  7. Pick the columns to subtotal. In the Add subtotal to list, tick the numeric columns you want summarized. Do not tick the grouping column itself, since summing a text column produces zeros.
  8. Set the checkboxes. Leave Replace current subtotals ticked if you are adding subtotals for the first time or replacing existing ones. Leave Page break between groups unticked unless you plan to print each group on its own page. Leave Summary below data ticked so the grand total appears at the bottom.
  9. Click OK. Excel inserts a subtotal row after each group, adds a grand total row at the end, and shows outline buttons (1, 2, 3) at the top left of the sheet. Click 1 to show only the grand total, 2 to show subtotals, and 3 to show everything.
  10. Collapse or expand groups. Use the small minus and plus buttons in the left margin next to each group to hide or show detail rows. The numbered buttons at the top left collapse or expand all groups at once.
  11. Remove subtotals when done. To clear them, go back to Data > Subtotal and click Remove All. This deletes the subtotal rows and the outline, leaving your original data intact.

Common Mistakes

  • Skipping the sort. The most common cause of messy results. If the grouping column is not sorted, Excel inserts a subtotal every time the value changes, so the same category can appear in several separate subtotal rows.
  • Leaving blank rows in the data. Excel stops detecting the range at the first blank row, so part of your data is left out. Delete blank rows first.
  • Ticking the grouping column in Add subtotal to. Text columns sum to zero, which makes the subtotal look broken.
  • Using Subtotal on a formatted Excel Table. The Subtotal button works 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.
  • Expecting it to work in Excel for the web. The web version does not include the Subtotal button. Open the file in the desktop app to insert subtotals.
  • Editing inside collapsed groups. Copying or pasting over hidden rows can overwrite data you cannot see. Expand the groups before making bulk edits.

Tips

  • Use the outline buttons (1, 2, 3) to switch between detail and summary views quickly, which is handy for screenshots or printing.
  • If you need subtotals that update automatically when data changes, a PivotTable is usually a better choice than the Subtotal button, because Subtotal results are static formulas that do not refresh with new rows.
  • You can run Subtotal more than once to add a second level of grouping (for example, subtotal by Region, then by Product). Untick Replace current subtotals the second time.
  • Keep the grouping column immediately to the left of the columns you are summarizing where possible; it makes the outline easier to read.
  • Format the subtotal rows with bold or a fill color so they stand out when you scan the sheet.

Troubleshooting

  • The Subtotal button is greyed out. Usually means no cell inside a data range is selected, or the sheet is protected. Click a cell inside the data, and check Review > Unprotect Sheet if protection is on.
  • Subtotals appear after every row. The grouping column is not sorted. Remove all subtotals, sort the column, then run Subtotal again.
  • Only some rows got subtotals. A blank row or blank column split the range. Delete blanks and rerun.
  • Subtotal values are zero. The column you ticked contains text, not numbers, or numbers stored as text. Check for leading apostrophes or cells formatted as Text.
  • Outline buttons disappeared. Go to File > Options > Advanced and look under Display options for this worksheet for Show outline symbols if an outline is applied. Turn it on.
  • Results did not update after editing data. Subtotal formulas do not recalculate automatically when you add rows outside the original range. Remove and reapply, or switch to a PivotTable.

Frequently Asked Questions

Does the Subtotal button work in Excel for the web?

No. The web version can display existing subtotals and outlines but does not include the Subtotal button. Use the desktop app to insert them.

Can I subtotal more than one column at once?

Yes. In the Add subtotal to list, tick as many numeric columns as you need. Each gets its own subtotal formula in the same subtotal row.

What is the difference between Subtotal and a PivotTable?

Subtotal inserts static formulas into your sheet. A PivotTable builds a separate summary that you can refresh when data changes. For one-off summaries, Subtotal is faster; for ongoing reports, a PivotTable is more flexible.

Can I add a second level of subtotals?

Yes. Sort by the first column, run Subtotal, then sort by the second column within groups and run Subtotal again with Replace current subtotals unticked. Excel nests the outline levels.

How do I remove subtotals without deleting my data?

Go to Data > Subtotal and click Remove All. This removes the subtotal rows and outline but leaves the original rows untouched.

Why does my grand total not match the sum of the subtotals?

Usually because some rows were outside the detected range (blank rows) or because the column contains text values that sum to zero. Check the range and the cell format.