# Subtotals on Multiple Levels in Microsoft Excel

By Alan Sembera

i Jupiterimages/Brand X Pictures/Getty Images

One of the lesser-known features of Excel is its ability to automatically generate subtotals on multiple levels using the application's Subtotal feature. If you keep sales figures in your worksheet, for example, you can create subtotals for sales in each region, plus nested subtotals broken down by state and even city. To implement multiple-level subtotals, first use Excel's advanced sorting function to rearrange your data into the right grouping levels.

## Step 1

Prepare your data for sorting by removing any empty rows or columns. Also, create a title row at the top of your data if you haven't already done so.

## Step 2

Select any cells containing data. If you want to apply subtotals to only part of the worksheet, select those rows instead.

## Step 3

Select the "Home" tab, click the "Sort & Filtering" command, and then select the "Custom Sort" option. Excel opens the Sort dialog box.

## Step 4

Click the "Sort By" drop-down menu and select the column you want to use to group your first-level subtotals. For example, if your data includes sales figures identified by Region, State and City, select the "Region" column to make the regional sales figures your first-level subtotals.

## Step 5

Click the "Then By" drop-down menu and select the column you want to use for your second-level subtotals. In the above example, if you want to create a second-level subtotal for each state within a region, select "state" from the drop-down list.

## Step 6

Repeat the previous step for any additional sub-total levels you want to create, such as city-level sales totals in the example.

## Step 7

Click "OK" to sort the data and close the dialog box.

## Step 1

Select any cell containing data. If you want to apply subtotals to only part of the worksheet, select those rows instead.

## Step 2

Select the "Data" tab and then click the "Subtotal" command in the Outline group. Excel opens the Subtotal dialog box.

## Step 3

Click the drop-down menu under "At Each Change In," and then select the column you want to use for your first-level subtotals. Select the same column you selected for your first-level sort. In the example used previously, you would select "Region" to create first-level subtotals based on regional sales.

## Step 4

Check one or more of the boxes in the "Add Subtotal To" pane to indicate which column contains your numbers. In the example, you might check the box next to "Sales Amounts."

## Step 5

Click "OK" to create your first-level subtotals.

## Step 6

Click the "Subtotal" command again to begin creating your second-level subtotal.

## Step 7

Click the drop-down menu under "At Each Change In," and then select the column you want to use for your second-level subtotals. In the example, you would select "State."

## Step 8

Check the same box in the "Add Subtotal To" pane that you checked previously.

## Step 9

Clear the check box next to "Replace Current Subtotals." Clearing this setting causes Excel to retain previous subtotal levels and create a new level.

## Step 10

Click "OK" to create you second-level subtotals. Repeat the steps for each additional level of subtotals you want to add, removing the check mark next to "Replace Current Subtotals" each time. You can create up to eight levels of subtotals.