The tutorial shows how to group rows in Excel to make complicated spreadsheets easier to read. See how you can quickly hide rows within a certain group or collapse the entire outline to a particular level.
Worksheets with a lot of complex and detailed information are difficult to read and analyze. Luckily, Microsoft Excel provides an easy way to organize data in groups allowing you to collapse and expand rows with similar content to create more compact and understandable views.
Grouping rows in Excel
Grouping in Excel works best for structured worksheets that have column headings, no blank rows or columns, and a summary row (subtotal) for each subset of rows. With the data properly organized, use one of the following ways to group it.
How to group rows automatically (create an outline)
If your dataset contains just one level of information, the fastest way would be to let Excel group rows for you automatically. Here's how:
- Select any cell in one of the rows you want to group.
- Go to the Data tab > Outline group, click the arrow under Group, and select Auto Outline.
That's all there is to it!
Here is an example of what kind of rows Excel can group:
As shown in the screenshot below, the rows have been grouped perfectly and the outline bars representing different levels of data organization have been added to the left of column A.
Note. If your summary rows are located above a group of detail rows, before creating an outline, go to the Data tab > Outline group, click the Outline dialog box launcher, and clear the Summary rows below detail checkbox.
Once the outline is created, you can quickly hide or show details within a certain group by clicking the minus or plus sign for that group. You can also collapse or expand all rows to a particular level by clicking on the level buttons in the top-left corner of the worksheet. For more information, please see How to collapse rows in Excel.
How to group rows manually
If your worksheet contains two or more levels of information, Excel's Auto Outline may not group your data correctly. In such a case, you can group rows manually by performing the steps below.
Note. When creating an outline manually, make sure your dataset does not contain any hidden rows, otherwise your data may be grouped incorrectly.
1. Create outer groups (level 1)
Select one of the larger subsets of data, including all of the intermediate summary rows and their detail rows.
In the dataset below, to group all data for row 9 (East Total), we select rows 2 through 8.
On the Data tab, in the Outline group, click the Group button, select Rows, and click OK.
This will add a bar on the left side of the worksheet that spans the selected rows:
In a similar manner, you create as many outer groups as necessary.
In this example, we need one more outer group for the North region. For this, we select rows 10 to 16, and click Data tab > Group button > Rows.
That set of rows is now grouped too:
Tip. To create a new group faster, press the Shift + Alt + Right Arrow shortcut instead of clicking the Group button on the ribbon.
2. Create nested groups (level 2)
To create a nested (or inner) group, select all detail rows above the related summary row, and click the Group button.
For example, to create the Apples group within the East region, select rows 2 and 3, and hit Group. To make the Oranges group, select rows 5 through 7, and press the Group button again.
Similarly, we create nested groups for the North regions, and get the following result:
3. Add more grouping levels if necessary
In practice, datasets are seldom complete. If at some point more data is added to your worksheet, you will probably want to create more outline levels.
As an example, let's insert the Grand total row in our table, and then add the outermost outline level. To have it done, select all the rows except for the Grand Total row (rows 2 through 17), and click Data tab > Group button > Rows.
As shown in the screenshot below, our data is now grouped in 4 levels:
- Level 1: Grand total
- Level 2: Region totals
- Level 3: Item subtotals
- Level 4: Detail rows
Now that we have an outline of rows, let's see how it makes our data easier to view.
How to collapse rows in Excel
One of the most useful features of Excel grouping is the ability to hide and show the detail rows for a particular group as well as to collapse or expand the entire outline to a certain level in a mouse click.
Collapse rows within a group
To collapse the rows in a particular group, just click the minus button at the bottom of that group's bar.
For example, this is how you can quickly hide all detail rows for the East region, including subtotals, and show only the East Total row:
Another way to collapse rows in Excel is to select any cell in the group and click the Hide Detail button on the Data tab, in the Outline group:
Either way, the group will be minimized to the summary row, and all of the detail rows will be hidden.
Collapse or expand the entire outline to a specific level
To minimize or expand all the groups at a particular level, click the corresponding outline number at the top left corner of your worksheet.
Level 1 displays the least amount of data while the highest number expands all the rows. For example, if your outline has 3 levels, you click number 2 to hide the 3rd level (detail rows) while displaying the other two levels (summary rows).
In our sample dataset, we have 4 outline levels, which work this way:
- Level 1 shows only Grand total (row 18 ) and hides all other rows.
- Level 2 displays Grand total and Region subtotals (rows 9, 17 and 18).
- Level 3 displays Grand total, Region and Item subtotals (rows 4, 8, 9, 18, 13, 16, 17 and 18).
- Level 4 shows all the rows.
The following screenshot demonstrates the outline collapsed to level 3.
How to expand rows in Excel
To expand the rows within a certain group, click any cell in the visible summary row, and then click the Show Detail button on the Data tab, in the Outline group:
Or click the plus sign for the collapsed group of rows that you want to expand:
How to remove outline in Excel
In case you want to remove all row groups at once, then clear the outline. If you want to remove just some of the row groups (e.g. nested groups), then ungroup the selected rows.
How to remove the entire outline
Go to the Data tab > Outline group, click the arrow under Ungroup, and then click Clear Outline.
Notes:
- Removing outline in Excel does not delete any data.
- If you remove an outline with some collapsed rows, those rows might remain hidden after the outline is cleared. To display the rows, use any of the methods described in How to unhide rows in Excel.
- Once the outline is removed, you won't be able to get it back by clicking the Undo button or pressing the Undo shortcut (Ctrl + Z). You will have to recreate the outline from scratch.
How to ungroup a certain group of rows
To remove grouping for certain rows without deleting the whole outline, do the following:
- Select the rows you want to ungroup.
- Go to the Data tab > Outline group, and click the Ungroup button. Or press Shift + Alt + Left Arrow which is the Ungroup shortcut in Excel.
- In the Ungroup dialog box, select Rows and click OK.
For example, here's how you can ungroup two nested row groups (Apples Subtotal and Oranges Subtotal) while keeping the outer East Total group:
Tips and notes:
- It is not possible to ungroup non-adjacent groups of rows at a time. You will have to repeat the above steps for each group individually.
- In Excel 365, you can use the GROUPBY function to group rows and aggregate values with a formula.
Excel grouping tips
As you have just seen, it's pretty easy to group rows in Excel. Below you will find a few useful tricks that will make your work with groups even easier.
How to calculate group subtotals automatically
In all of the above examples, we have inserted our own subtotal rows with SUM formulas. To have subtotals calculated automatically, use the Subtotal command with the summary function of your choice such as SUM, COUNT, AVERAGE, MIN, MAX, etc. The Subtotal command will not only insert summary rows but also create an outline with collapsible and expandable rows, thus completing two tasks at once!
Apply default Excel styles to summary rows
Microsoft Excel has the predefined styles for two levels of summary rows: RowLevel_1 (bold) and RowLevel_2 (italic). You can apply these styles before or after grouping rows.
To automatically apply Excel styles to a new outline, go to the Data tab > Outline group, click the Outline dialog box launcher, and then select the Automatic styles check box, and click OK. After that you create an outline as usual.
To apply styles to an existing outline, you also select the Automatic styles box as shown above, but click the Apply Styles button instead of OK.
Here's how an Excel outline with the default styles for summary rows looks like:
How to select and copy only visible rows
After you've collapsed irrelevant rows, you may want to copy the displayed relevant data somewhere else. However, when you select the visible rows in the usual way using the mouse, you are actually selecting the hidden rows as well.
To select only the visible rows, you'll need to perform a few extra steps:
- Select visible rows using the mouse.
For example, we have collapsed all of the detail rows, and now select the visible summary rows:
- Head to the Home tab >Editing group, and click Find & Select > Go To Special. Or press Ctrl + G (Go To shortcut) and click the Special… button.
- In the Go To Special dialog box, select Visible cells only and click OK.
As the result, only the visible rows are selected (the rows adjacent to hidden rows are marked with a white border):
And now, you simply press Ctrl + C to copy the selected rows and Ctrl + V to paste them wherever you like.
How to hide and show outline symbols
To hide or display the outline bars and level numbers in Excel, use the following keyboard shortcut: Ctrl + 8.
Pressing the shortcut for the first time hides the outline symbols, pressing it again redisplays the outline.
The outline symbols don't show up in Excel
If you can see neither the plus and minus symbols in the group bars nor the numbers at the top of the outline, check the following setting in your Excel:
- Go to the File tab > Options > Advanced category.
- Scroll down to the Display options for this worksheet section, select the worksheet of interest, and make sure the Show outline symbols if an outline is applied box is selected.
This is how you group rows in Excel to collapse or expand certain sections of your dataset. In a similar fashion, you can group columns in your worksheets. I thank you for reading and hope to see you on our blog next week.
56 comments
Hi!
I want to create a PR plan and use grouping for activities related to the same main activity, but run to problems. I want to group 2-10 rows leaving the first row visible to mark the main activiti.
For example my activity item is an article published on my website and have 5 items related to it. Now if I group all of these 6 rows, they all collide and hide. I can leave the first row ungrouped, but that wouldn't be the point of grouping.
And if I have only 2 activites, then it wouldn't make any sense to group 1 row and leave one row visible.
So long story short: how can I group rows in a way that would leave the first row visible?
Is there a way to move the (+) symbol in line with the row the subset of data corresponds to? Excel is automatically placing the symbol one row down.
Alt, A, L; This opens the settings menu. Then make sure to uncheck the "Summary rows before detail" box.
Hi - This is useful but does not help with my much simpler problem. I will use a simple example to explain my problem
Column A is School
Column B is Student
So there will be multiple occurrences of the same School value on consecutive rows for each student
I would like to be able to group by School automatically so as to be able to expand/collapse School to reveal and collapse to show all students. I have no wish to sum anything, this is purely to make the sheet manageable
Any ideas - this seems like it should be simple
Really, it is very useful.
I have a sorted column and want to create a group whenever the value value in the column changes. I get a 'Cannot create an outline' error message. There are hundreds of value changes. Is there a size limit to this feature.
Thanks
Hello!
My outline symbols are not visible. The box is checked in advanced and I tried the ctrl + 8 and nothing is working! Please advise!
How does this work if there is no arrow in low right corner?
How can I open that sub menu?
Thank you for the Outline Symbols Don't Show Up fix. I had 1 workbook with 5 sheets... and they would not show the group row symbols. If I clicked on "Show Detail" or "Hide Detail" in Outline Menu it would group, but with no way to see multi level groupings. I created 5 NEW sheets (same workbook) and copied the data and the new worksheets would show the group symbols. So question is, did I accidentally do a keyboard combination that "turned off" (or unchecked) the Show Symbol in the Advance Options? Just hoping to prevent that from occurring again.
Hi Folks,
When I unchecked the View under Headings in the Page Layout tab the Level Buttons disappears.
Is there a way to move or relocate the Level Buttons anchored to top level corner or have the Level Buttons not disappear?
Any help would be greatly appreciated! Thank you!
How to group in Excel
Is there a shortcut to hide the rows after using Shift-Alt-Right arrow to group them?
Hi Jeff,
You can use the Ctrl + 9 shortcut to hide rows and Ctrl + Shift + 9 to unhide.
Is there any way to make a group, which contains all the rows in a table, extend by one row everytime you add a row to the table?
Hi and thanks for the detailed information. My query is rather simple, but cant find how to do it.
I have 90 groups of 11 rows, the first row of each 11 rows is a heading and I have laid them out alphabetically. How can I add another group of 11 rows between two sets of groups WITHOUT creating another level of grouping?
How to hide ribbons only for one sheet in a workbook?
need help please
Mohammed:
The only way I know to hide the ribbons or formula bars for one worksheet is by using some VBA code.
There are various approaches to accomplishing this. You can find them by searching Google with Hide Ribbons in Excel.
Hi! Thanks for the information. I do have a special question:
Let's asume I have grouped rows from 10 to 15. Now I insert a new blank line above line 10 (e.g. above row 2). Grouping now remains in rows 10 to 15, but I want to have it shifted one row down to 11 to 16 (as the data is there). Is there any chance to "attach" the grouping to data instead of row-numbers?
Sorry, I need to add the information, that I formatted row 1 to 8 as a table! If I add a row in this table, then the grouping remains on row 10 to 15. If I do not format row 1 to 8 as table, grouping shifts one row down if a blank row is inserted
Hi
Awesome information, thanks
I have a question, Is there a way to name the groups?
I would like to see if this can be posible
thanks
Hi,
My data group function isn't working on one page in a workbook....works fine on the others.
Any ideas how to fix it?
Thanks, Becky
Hello,
Is there a way to record/write a macro that hides/unhide specific grouped rows? I want to be able to further customize the data that is being viewed by the user. - Simply writing VBA code that hides/unhides specific rows/columns within the worksheet does not seem to work when the data is outlined/grouped.
Thanks!
Dear,
I want to copy different cell and rows and paste in another sheet as group data by excel vb. Thanks in advance.
Hi there,
Thanks so much for this, it is super helpful! I have followed this and have grouped rows under certain categories and it is clean and easy to follow. However, I created a Pivot Table and this does not seem to recognize the grouped rows in the data set. More specifically, I have listed item names (which is the pivot table filter) at the top of each of the grouped rows but it does not repeat within the rows - so the pivot table isn't reading the below rows as being within the filter item resulting in the pivot table not working. Is there a quick fix to this? Or do I need to put the filter item in every row within the groups in the data set? Thanks in advance for your help.
Hello,
For me to understand the problem better, please send me a small sample workbook with your source data and the result you expect to get to support@ablebits.com. Please don't worry if you have confidential information there, we never disclose the data we get from our customers and delete it as soon as the problem is resolved.
Please also don't forget to include the link to this comment into your email.
I'll look into your task and try to help.