How to Automatically Group and Outline Data Using Subtotals in Microsoft Excel

When analyzing a large financial spreadsheet containing hundreds of rows, you often need to calculate the totals for specific groups of data. For example, if you have a list of sales transactions sorted by region (North, South, East, West), you might want to see the total revenue for each individual region. While you could manually insert blank rows and type =SUM() formulas over and over, Microsoft Excel features a powerful Subtotal tool that will automatically outline and group your data in seconds.

Preparing Your Data

The Subtotal feature relies entirely on organization. Before you click the tool, you must sort your data based on the column you want to group by. If you do not sort the data first, the tool will malfunction and insert a subtotal break every time the data changes randomly.

  1. Look at your dataset and identify the grouping column (e.g., the “Region” column).
  2. Click anywhere inside that column.
  3. Go to the Data tab on the ribbon menu and click the Sort A to Z button.

Your spreadsheet should now be perfectly organized, with all the “East” rows clustered together, followed by all the “North” rows.

How to Apply the Subtotal Tool

Once your data is cleanly sorted, you can apply the automated calculations.

  1. Click anywhere inside your main data table.
  2. Navigate to the Data tab in the main ribbon menu.
  3. Look for the “Outline” group on the far right side of the ribbon. Click the Subtotal button.

A dialog box will appear asking you to define the calculation logic.

  • At each change in: Use the drop-down menu to select the column you just sorted (e.g., “Region”). This tells Excel when to trigger the calculation.
  • Use function: Select the mathematical operation you want to perform. “Sum” is the most common, but you can also choose Average, Count, Max, or Min.
  • Add subtotal to: Check the box next to the column containing the numbers you want to calculate (e.g., check the box for “Revenue”).

Click OK. Excel will instantly scan the document. The moment it detects that the data in the “Region” column has changed from East to North, it will automatically insert a brand-new row, write the word “East Total,” and calculate the exact mathematical sum of the revenue above it. It will repeat this for every region, and place a “Grand Total” at the very bottom of the document.

Using the Outline Controls

Once the subtotals are generated, you will notice a new, grey margin has appeared on the far left side of your screen containing the numbers 1, 2, and 3. This is the Outline control panel.

  • Clicking 3: Shows all the raw data and all the subtotals (the default view).
  • Clicking 2: Instantly hides all the raw data rows, collapsing the spreadsheet to show only the clean subtotal summaries for each region.
  • Clicking 1: Collapses everything to show only the final Grand Total.

To completely remove the subtotals and return your spreadsheet to normal, click the Subtotal button on the Data tab again, and click the Remove All button at the bottom of the dialog box.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.