How to group rows in excel with expand/collapse

This is the last in a series of tips related to the Excel’s Subtotal feature which automatically inserts subtotals and grand totals into a list and groups the rows into a collapsible outline. Auto sum only works in certain situations. When it doesn’t work you can still accomplish the same thing with just a little more effort. Last month I explained how to write subtotal formulas. Now I’ll show you how to create the collapsible outline.

If you have a long report in Excel that already has subtotals in it, and you want to make it more manageable, that’s a perfect time to manually set up grouping.

Simply select all of the rows that you want to be able to hide (collapse) but not the row totaling them. Then click the Group button, which is located on the Data tab of the ribbon. In the left margin you’ll see a line appear next to the rows you just grouped. At the bottom will be a small box with a minus sign in it. Click that box to collapse or roll up those rows. The box now change to a plus sign. Click it to expand that section.

Now simply repeat that process for each section you want to be able to collapse. You can even select a larger group of rows that already have groups set up within them. Then you can choose which level of detail you want to be able to see. As you add levels, numbered boxes will appear at the top of the left margin allowing you to expand or collapse everything to the corresponding detail level.

To undo a grouping, select those rows again and click the Ungroup button.To get rid of all of your groupings, simply click the down arrow below the Ungroup button and choose Clear Outline.

One additional option is called Auto Outline. To have Excel automatically create groups, click the down arrow below the Group button and choose Auto Outline. If you don’t like the result, clear the outline and manually create the groups any way you want.

If you have a list of data you want to group and summarize, you can create an outline of up to eight levels. Each inner level, represented by a higher number in the outline symbols, displays detail data for the preceding outer level, represented by a lower number in the outline symbols. Use an outline to quickly display summary rows or columns, or to reveal the detail data for each group. You can create an outline of rows (as shown in the example below), an outline of columns, or an outline of both rows and columns.

How to group rows in excel with expand/collapse

1.  To display rows for a level, click the appropriate

How to group rows in excel with expand/collapse
outline symbols.

2.  Level 1 contains the total sales for all detail rows.

3.  Level 2 contains total sales for each month in each region.

4.  Level 3 contains detail rows — in this case, rows 17 through 20.

5.  To expand or collapse data in your outline, click the

How to group rows in excel with expand/collapse
and
How to group rows in excel with expand/collapse
outline symbols, or press ALT+SHIFT+= to expand and ALT+SHIFT+- to collapse.

  1. Make sure that each column of the data that you want to outline has a label in the first row (e.g., Region), contains similar facts in each column, and that the range you want to outline has no blank rows or columns.

  2. If you want, your grouped detail rows can have a corresponding summary row—a subtotal. To create these, do one of the following:

    • Insert summary rows by using the Subtotal command    

      Use the Subtotal command, which inserts the SUBTOTAL function immediately below or above each group of detail rows and automatically creates the outline for you. For more information about using the Subtotal function, see SUBTOTAL function.

    • Insert your own summary rows    

      Insert your own summary rows, with formulas, immediately below or above each group of detail rows. For example, under (or above) the rows of sales data for March and April, use the SUM function to subtotal the sales for those months. The table later in this topic shows you an example of this.

  3. By default, Excel looks for summary rows below the details they summarize, but it's possible to create them above the detail rows. If you created the summary rows below the details, skip to the next step (step 4). If you created your summary rows above your detail rows, on the Data tab, in the Outline group, click the dialog box launcher.

    How to group rows in excel with expand/collapse

    The Settings dialog box opens.

    How to group rows in excel with expand/collapse

    Then in the Settings dialog box, clear the Summary rows below detail checkbox, and then click OK.

  4. Outline your data. Do one of the following:

    Outline the data automatically

    1. Select a cell in the range of cells you want to outline.

    2. On the Data tab, in the Outline group, click the arrow under Group, and then click Auto Outline.

      How to group rows in excel with expand/collapse

    Outline the data manually

    Important: When you manually group outline levels, it's best to have all data displayed to avoid grouping the rows incorrectly.

    1. To outline the outer group (level 1), select all of the rows the outer group will contain (i.e., the detail rows and if you added them, their summary rows).

      How to group rows in excel with expand/collapse

      1. The first row contains labels, and is not selected.

      2. Since this is the outer group, select all the rows with subtotals and details.

      3. Don't select the grand total.

    2. On the Data tab, in the Outline group, click Group. Then in the Group dialog box, click Rows, and then click OK.

      Tip: If you select entire rows instead of just the cells, Excel automatically groups by row - the Group dialog box doesn't even open.

      How to group rows in excel with expand/collapse

      The outline symbols appear beside the group on the screen.

    3. Optionally, outline an inner, nested group — the detail rows for a given section of your data.

      Note: If you don't need to create any inner groups, skip to step f, below.

      For each inner, nested group, select the detail rows adjacent to the row that contains the summary row.

      How to group rows in excel with expand/collapse

      1. You can create multiple groups at each inner level. Here, two sections are already grouped at level 2.

      2. This section is selected and ready to group.

      3. Don't select the summary row for the data you are grouping.

    4. On the Data tab, in the Outline group, click Group.

      How to group rows in excel with expand/collapse

      Then in the Group dialog box, click Rows, and then click OK. The outline symbols appear beside the group on the screen.

      Tip: If you select entire rows instead of just the cells, Excel automatically groups by row - the Group dialog box doesn't even open.

    5. Continue selecting and grouping inner rows until you have created all of the levels that you want in the outline.

    6. If you want to ungroup rows, select the rows, and then on the Data tab, in the Outline group, click Ungroup.

      You can also ungroup sections of the outline without removing the entire level. Hold down SHIFT while you click the

      How to group rows in excel with expand/collapse
      or
      How to group rows in excel with expand/collapse
      for the group, and then on the Data tab, in the Outline group, click Ungroup.

      Important: If you ungroup an outline while the detail data is hidden, the detail rows may remain hidden. To display the data, drag across the visible row numbers adjacent to the hidden rows. Then on the Home tab, in the Cells group, click Format, point to Hide & Unhide, and then click Unhide Rows.

  1. Make sure that each row of the data that you want to outline has a label in the first column, contains similar facts in each row, and the range has no blank rows or columns.

  2. Insert your own summary columns with formulas immediately to the right or left of each group of detail columns. The table listed in step 4 below shows you an example.

    Note: To outline data by columns, you must have summary columns that contain formulas that reference cells in each of the detail columns for that group.

  3. If your summary column is to the left of the detail columns, on the Data tab, in the Outline group, click the dialog box launcher.

    How to group rows in excel with expand/collapse

    The Settings dialog box opens.

    How to group rows in excel with expand/collapse

    Then in the Settings dialog box, clear the Summary columns to right of detail check box, and click OK.

  4. To outline the data, do one of the following:

    Outline the data automatically

    1. Select a cell in the range.

    2. On the Data tab, in the Outline group, click the arrow below Group and click Auto Outline.

    Outline the data manually

    Important: When you manually group outline levels, it's best to have all data displayed to avoid grouping columns incorrectly.

    1. To outline the outer group (level 1), select all of the subordinate summary columns, as well as their related detail data.

      How to group rows in excel with expand/collapse

      1. Column A contains labels.

      2. Select all the detail and subtotal columns. Note that if you don't select entire columns, when you click Group (on the Data tab in the Outline group) the Group dialog box will open and ask you to choose Rows or Columns.

      3. Don't select the grand total column.

    2. On the Data tab, in the Outline group, click Group.

      How to group rows in excel with expand/collapse

      The outline symbol appears above the group.

    3. To outline an inner, nested group of detail columns (level 2 or higher), select the detail columns adjacent to the column that contains the summary column.

      How to group rows in excel with expand/collapse

      1. You can create multiple groups at each inner level. Here, two sections are already grouped at level 2.

      2. These columns are selected and ready to group. Note that if you don't select entire columns, when you click Group (on the Data tab in the Outline group) the Group dialog box will open and ask you to choose Rows or Columns.

      3. Don't select the summary column for the data you are grouping.

    4. On the Data tab, in the Outline group, click Group.

      How to group rows in excel with expand/collapse

      The outline symbols appear beside the group on the screen.

  5. Continue selecting and grouping inner columns until you have created all of the levels that you want in the outline.

  6. If you want to ungroup columns, select the columns, and then on the Data tab, in the Outline group, click Ungroup.

How to group rows in excel with expand/collapse

You can also ungroup sections of the outline without removing the entire level. Hold down SHIFT while you click the

How to group rows in excel with expand/collapse
or
How to group rows in excel with expand/collapse
for the group, and then on the Data tab, in the Outline group, click Ungroup.

If you ungroup an outline while the detail data is hidden, the detail columns may remain hidden. To display the data, drag across the visible column letters adjacent to the hidden columns. On the Home tab, in the Cells group, click Format, point to Hide & Unhide, and then click Unhide Columns

  1. If you don't see the outline symbols

    How to group rows in excel with expand/collapse
    ,
    How to group rows in excel with expand/collapse
    , and
    How to group rows in excel with expand/collapse
    , go to FileOptions Advanced, and then under the Display options for this worksheet section, select the Show outline symbols if an outline is applied check box, and then click OK.

  2. Do one or more of the following:

    • Show or hide the detail data for a group    

      To display the detail data within a group, click the

      How to group rows in excel with expand/collapse
      button for the group, or press ALT+SHIFT+=.

    • To hide the detail data for a group, click the

      How to group rows in excel with expand/collapse
      button for the group, or press ALT+SHIFT+-.

    • Expand or collapse the entire outline to a particular level    

      In the

      How to group rows in excel with expand/collapse
      outline symbols, click the number of the level that you want. Detail data at lower levels is then hidden.

      For example, if an outline has four levels, you can hide the fourth level while displaying the rest of the levels by clicking

      How to group rows in excel with expand/collapse
      .

    • Show or hide all of the outlined detail data    

      To show all detail data, click the lowest level in the

      How to group rows in excel with expand/collapse
      outline symbols. For example, if there are three levels, click
      How to group rows in excel with expand/collapse
      .

    • To hide all detail data, click

      How to group rows in excel with expand/collapse
      .

For outlined rows, Microsoft Excel uses styles such as RowLevel_1 and RowLevel_2 . For outlined columns, Excel uses styles such as ColLevel_1 and ColLevel_2. These styles use bold, italic, and other text formats to differentiate the summary rows or columns in your data. By changing the way each of these styles is defined, you can apply different text and cell formats to customize the appearance of your outline. You can apply a style to an outline either when you create the outline or after you create it.

Do one or more of the following:

Automatically apply a style to new summary rows or columns    

  1. On the Data tab, in the Outline group, click the dialog box launcher.

    How to group rows in excel with expand/collapse

    The Settings dialog box opens.

    How to group rows in excel with expand/collapse

  2. Select the Automatic styles check box.

Apply a style to an existing summary row or column    

  1. Select the cells to which you want to apply a style.

  2. On the Data tab, in the Outline group, click the dialog box launcher.

    How to group rows in excel with expand/collapse

    The Settings dialog box opens.

    How to group rows in excel with expand/collapse

  3. Select the Automatic styles check box, and then click Apply Styles.

    How to group rows in excel with expand/collapse

You can also use autoformats to format outlined data.

  1. If you don't see the outline symbols

    How to group rows in excel with expand/collapse
    ,
    How to group rows in excel with expand/collapse
    , and
    How to group rows in excel with expand/collapse
    , go to FileOptions Advanced, and then under the Display options for this worksheet section, select the Show outline symbols if an outline is applied check box.

  2. Use the outline symbols

    How to group rows in excel with expand/collapse
    ,
    How to group rows in excel with expand/collapse
    , and
    How to group rows in excel with expand/collapse
    to hide the detail data that you don't want copied.

    For more information, see the section, Show or hide outlined data.

  3. Select the range of summary rows.

  4. On the Home tab, in the Editing group, click Find & Select, and then click Go To.

    How to group rows in excel with expand/collapse

  5. Click Go To Special.

  6. Click Visible cells only.

  7. Click OK, and then copy the data.

Imagine that you want to create a summary report of your data that only displays totals accompanied by a chart of those totals. In general, you can do the following:

  1. Create a summary report

  2. Chart the summary report

    1. Select the summary data that you want to chart.

      For example, to chart only the Buchanan and Davolio totals, but not the grand totals, select cells A1 through C19 as shown in the above example.

    2. Click Insert > Charts > Recommended Charts, then click the All Charts tab and choose your chart type.

      How to group rows in excel with expand/collapse

      For example, if you chose the Clustered Column option, your chart would look like this:

      How to group rows in excel with expand/collapse

      If you show or hide details in the outlined list of data, the chart is also updated to show or hide the data.

You can group (or outline) rows and columns in Excel for the web.

Note: Although you can add summary rows or columns to your data (by using functions such as SUM or SUBTOTAL), you cannot apply styles or set a position for summary rows and columns in Excel for the web.

How to group rows in excel with expand/collapse

How to group rows in excel with expand/collapse

Outline of rows in Excel Online

  1. The first column contains labels.

  2. The detail rows and summary rows are grouped in the outline.

  3. The grand total is not grouped in the outline.

Outline of columns in Excel Online

  1. The first row contains labels.

  2. The detail columns and summary columns are grouped in the outline.

  3. The grand total is not grouped in the outline.

  1. Make sure that each column (or row) of the data that you want to outline has a label in the first row (or column), contains similar facts in each column (or row), and that the range has no blank rows or columns.

  2. Select the data (including any summary rows or columns).

  3. On the Data tab, in the Outline group, click Group > Group Rows or Group Columns.

  4. Optionally, if you want to outline an inner, nested group — select the rows or columns within the outlined data range, and repeat step 3.

  5. Continue selecting and grouping inner rows or columns until you have created all of the levels that you want in the outline.

  • To ungroup, select the rows or columns, and then on the Data tab, in the Outline group, click Ungroup and select Ungroup Rows or Ungroup Columns.

Do one or more of the following:

Show or hide the detail data for a group    

  • To display the detail data within a group, click the

    How to group rows in excel with expand/collapse
    for the group, or press ALT+SHIFT+=.

  • To hide the detail data for a group, click the

    How to group rows in excel with expand/collapse
    for the group, or press ALT+SHIFT+-.

Expand or collapse the entire outline to a particular level    

  • In the

    How to group rows in excel with expand/collapse
    outline symbols, click the number of the level that you want. Detail data at lower levels is then hidden.

  • For example, if an outline has four levels, you can hide the fourth level while displaying the rest of the levels by clicking

    How to group rows in excel with expand/collapse
    .

Show or hide all of the outlined detail data    

  • To show all detail data, click the lowest level in the

    How to group rows in excel with expand/collapse
    outline symbols. For example, if there are three levels, click
    How to group rows in excel with expand/collapse
    .

  • To hide all detail data, click

    How to group rows in excel with expand/collapse
    .

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Group or ungroup data in a PivotTable

How to group rows in excel with expand/collapse
How to group rows in excel with expand/collapse
How to group rows in excel with expand/collapse