Insert subtotals in a list of data in a worksheet

You can automatically calculate subtotals and grand totals in a list for a column by using the Subtotal command.

 Important   

The Subtotal command will appear grayed out if you are working with a Microsoft Excel table. To add subtotals in a table, you must first convert the table to a normal range of data, and then add the subtotal. Note that this will remove all table functionality from the data except table formatting.

When you insert subtotals:

Example of automatic subtotals

If the workbook is set to automatically calculate formulas, the Subtotal command recalculates subtotal and grand total values automatically as you edit the detail data. The Subtotal command also outlines (outline: Worksheet data in which rows or columns of detail data are grouped so that you can create summary reports. The outline can summarize either an entire worksheet or a selected portion of it.) the list so that you can display and hide the detail rows for each subtotal.

What do you want to do?


Insert subtotals

 Note    If you filter data that contains subtotals, your subtotals may appear hidden. To display them again, clear all filters For more information on applying filters, see Quick start: Filter data by using an AutoFilter.

  1. Make sure that each column in a range (range: Two or more cells on a sheet. The cells in a range can be adjacent or nonadjacent.) of data for which you want to calculate subtotals has a label in the first row, contains similar facts in each column, and that the range does not include any blank rows or columns.
  2. Select a cell in the range.
  3. Do one of the following:

ShowInsert one level of subtotals

You can insert one level of subtotals for a group of data as shown in the following example.

Example of automatic subtotals

Callout 1 At each change in the Sport column…
Callout 2 …subtotal the Sales column.
  1. To sort the column that contains the data you want to group by, select that column, and then on the Data tab, in the Sort & Filter group, click Sort A to Z or Sort Z to A.
  2. On the Data tab, in the Outline group, click Subtotal.

Outlook Ribbon Image

The Subtotal dialog box is displayed.

  1. In the At each change in box, click the column to subtotal. For example, using the example above, you would select Sport.
  2. In the Use function box, click the summary function that you want to use to calculate the subtotals. For example, using the example above, you would select Sum.
  3. In the Add subtotal to box, select the check box for each column that contains values that you want to subtotal. For example, using the example above, you would select Sales.
  4. If you want an automatic page break following each subtotal, select the Page break between groups check box.
  5. To specify a summary row above the details row, clear the Summary below data check box. To specify a summary row below the details row, select the Summary below data check box. For example, using the example above, you would clear the check box.
  6. Optionally, you can use the Subtotals command again by repeating steps one through seven to add more subtotals with different summary functions. To avoid overwriting the existing subtotals, clear the Replace current subtotals check box.

ShowInsert nested levels of subtotals

You can insert subtotals for inner, nested groups within their corresponding outer groups as shown in the following example.

Example of outer and nested subtotals

Callout 1 At each change in the outer, Region column…
Callout 2 …subtotal the Sales for that region and at each change for the inner, Sport column.
  1. To sort the column that contains the data you want to group by, select that column, and then on the Data tab, in the Sort & Filter group, click Sort A to Z or Sort Z to A.
  2. Insert the outer subtotals.

ShowHow to insert the outer subtotals

  1. On the Data tab, in the Outline group, click Subtotal.

Outlook Ribbon Image

The Subtotal dialog box is displayed.

  1. In the At each change in box, click the column for the outer subtotals. For example, using the example above, you would click Region.
  2. In the Use function box, click the summary function that you want to use to calculate the subtotals. For example, using the example above, you would select Sum.
  3. In the Add subtotal to box, select the check box for each column that contains values that you want to subtotal. In the example above, you would select Sales.
  4. If you want an automatic page break following each subtotal, select the Page break between groups check box.
  5. To specify a summary row above the details row, clear the Summary below data check box. To specify a summary row below the details row, select the Summary below data check box. For example, using the example above, you would clear the check box.
  6. Optionally, you can use the Subtotals command again by repeating steps one through six to add more subtotals with different summary functions. To avoid overwriting the existing subtotals, clear the Replace current subtotals check box.
  1. Insert the nested subtotals.

ShowHow to insert the nested subtotals

  1. On the Data tab, in the Outline group, click Subtotal.

Outlook Ribbon Image

The Subtotal dialog box is displayed.

  1. In the At each change in box, click the nested subtotal column. For example, using the example above, you would select Sport.
  2. In the Use function box, click the summary function that you want to use to calculate the subtotals. For example, using the example above, you would select Sum.

Select any other options that you want.

  1. Clear the Replace current subtotals check box.
  1. Repeat the previous step for more nested subtotals, working from the outermost subtotals in.

Tip    To display a summary of just the subtotals and grand totals, click the outline symbols one two three next to the row numbers. Use the plus and minus symbols to display or hide the detail rows for individual subtotals.

Top of Page Top of Page

Remove subtotals

  1. Select a cell in the range that contains subtotals.
  2. On the Data tab, in the Outline group, click Subtotal.

Outlook Ribbon Image

  1. In the Subtotal dialog box, click Remove All.

Top of Page Top of Page

 
 
Applies to:
Excel 2010