Sei sulla pagina 1di 3

Excel > Filtering and sorting

Insert subtotals in a list of data in a worksheet


Show All
Hide All
You can automatically calculate subtotals and grand totals in a list for a colum
n 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:
Subtotals are calculated with a summary function (summary function: A type of
calculation that combines source data in a PivotTable report or a consolidation
table, or when you are inserting automatic subtotals in a list or database. Exam
ples of summary functions include Sum, Count, and Average.), such as Sum or Aver
age, by using the SUBTOTAL function. You can display more than one type of summa
ry function for each column.
Grand totals are derived from detail data (detail data: For automatic subtotal
s and worksheet outlines, the subtotal rows or columns that are totaled by summa
ry data. Detail data is typically adjacent to and either above or to the left of
the summary data.), not from the values in the subtotals. For example, if you u
se the Average summary function, the grand total row displays an average of all
of the detail rows in the list, not an average of the values in the subtotal row
s.

If the workbook is set to automatically calculate formulas, the Subtotal command


recalculates subtotal and grand total values automatically as you edit the deta
il data. The Subtotal command also outlines (outline: Worksheet data in which ro
ws 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 i
t.) the list so that you can display and hide the detail rows for each subtotal.
What do you want to do?
-------------------------------------------------------------------------------Insert subtotals
Remove subtotals
-------------------------------------------------------------------------------Insert subtotals
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.
Select a cell in the range.
Do one of the following:
Insert one level of subtotals

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

At each change in the Sport column


subtotal the Sales column.
To sort the column that contains the data you want to group by, select that colu
mn, and then on the Data tab, in the Sort & Filter group, click Sort A to Z or S
ort Z to A.
On the Data tab, in the Outline group, click Subtotal.
The Subtotal dialog box is displayed.
In the At each change in box, click the column to subtotal. For example, using t
he example above, you would select Sport.
In the Use function box, click the summary function that you want to use to calc
ulate the subtotals. For example, using the example above, you would select Sum.
In the Add subtotal to box, select the check box for each column that contains v
alues that you want to subtotal. For example, using the example above, you would
select Sales.
If you want an automatic page break following each subtotal, select the Page bre
ak between groups check box.
To specify a summary row above the details row, clear the Summary below data che
ck 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.
Optionally, you can use the Subtotals command again by repeating steps one throu
gh seven to add more subtotals with different summary functions. To avoid overwr
iting the existing subtotals, clear the Replace current subtotals check box.
Insert nested levels of subtotals
You can insert subtotals for inner, nested groups within their corresponding out
er groups as shown in the following example.

At each change in the outer, Region column


subtotal the Sales for that region and at each change for the inner, Sport colum
n.
To sort the column that contains the data you want to group by, select that colu
mn, and then on the Data tab, in the Sort & Filter group, click Sort A to Z or S
ort Z to A.
Insert the outer subtotals.
How to insert the outer subtotals
On the Data tab, in the Outline group, click Subtotal.
The Subtotal dialog box is displayed.

In the At each change in box, click the column for the outer subtotals. For exam
ple, using the example above, you would click Region.
In the Use function box, click the summary function that you want to use to calc
ulate the subtotals. For example, using the example above, you would select Sum.
In the Add subtotal to box, select the check box for each column that contains v
alues that you want to subtotal. In the example above, you would select Sales.
If you want an automatic page break following each subtotal, select the Page bre
ak between groups check box.
To specify a summary row above the details row, clear the Summary below data che
ck 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.
Optionally, you can use the Subtotals command again by repeating steps one throu
gh six to add more subtotals with different summary functions. To avoid overwrit
ing the existing subtotals, clear the Replace current subtotals check box.
Insert the nested subtotals.
How to insert the nested subtotals
On the Data tab, in the Outline group, click Subtotal.
The Subtotal dialog box is displayed.
In the At each change in box, click the nested subtotal column. For example, usi
ng the example above, you would select Sport.
In the Use function box, click the summary function that you want to use to calc
ulate the subtotals. For example, using the example above, you would select Sum.
Select any other options that you want.
Clear the Replace current subtotals check box.
Repeat the previous step for more nested subtotals, working from the outermost s
ubtotals in.
Tip To display a summary of just the subtotals and grand totals, click the outl
ine symbols next to the row numbers. Use the and symbols to display or hide t
he detail rows for individual subtotals.
Top of Page
Remove subtotals
Select a cell in the range that contains subtotals.
On the Data tab, in the Outline group, click Subtotal.
In the Subtotal dialog box, click Remove All.
Top of Page

Potrebbero piacerti anche