How to group rows in Excel

Today we would be taking you through grouping rows in excel. Grouping rows is very useful for presentation purposes especially for complex models with thousands of lines of information. It is usually used to organize complicated analysis or information in a straight forward manner so that it is easier to read and understand.

Grouping Rows in Excel

In this section we would review two methods of grouping rows in excel. The first is the auto outline option, the second is manual grouping. Without further ado, let’s delve into it:

Automatic Grouping through Auto Outline

This method of grouping is quite rigid and a few things have to be in place before it can work. One of which is that there should be a parent row for each category with a connection to the subordinating rows. You would understand better as we proceed with the steps

Step 1: Arrange your document with the parent (summary) rows either at the top or bottom of subordinate rows, then select a cell within the rows you want to group

Auto Group Step 1

Step 2: Navigate to the data tab > Outline, click the arrow under Group and select Auto Outline

Auto Group Step 2

You should have a similar result with the below

Auto Group Step 3

Note: There should be a relationship between the data for this to work correctly. For instance, the total rows (which represent the booking market) in our example sum up both the market size and revenue of the different trade regions in each booking market. This tells excel that those rows summed up are under the rows with the total. Without this sum, we would get the error notification below when we try to auto outline.

Auto Group Step 4

Manual Grouping

For data sets with two or more levels, the auto outline option may not group your data correctly. To do this, you would need to know how you want your data organized and grouped, then you can follow these simple steps to get the job done.

Let’s use our previous example but add new levels to the data.

Group rows with levels 1

As you can see, there are sub-levels for each booking market treated in this example. To group this data neatly we would need to create an outer group and then a nested group.

Creating an Outer Group

The outer group is the larger dataset. For example the UK total (row 14) is an outer group, so also is the North America total (row 27). To group the outer groups, follow these steps:

Step 1: Select all the intermediate summary rows and detail rows. This means that for UK we would select from row 2 to row 13.

Manual Grouping Step 1

Step 2: Navigate to the Data tab > Outline > Group and click on Group

Manual Grouping Step 2 1

Step 3: On selecting Group, you would see the selection box below, select rows and click on ok

Manual Grouping Step 3

Result: Excel adds a bar on the left side of the worksheet that spans the selected rows

Manual Grouping Step 4

Creating an Inner Group (Nested Group)

The process is pretty much the same as that of creating outer groups. Let’s walk you through the steps

Step 1: Select the detail row above the related summary row. For example, let’s group Europe in our example, we need to select from row 2 to 4.

Group rows with second level

Step 2: Navigate to the Data tab > Outline > Group and click on Group

Group rows with second level step 3

S

Step 3: Select rows in the selection box and click on ok.

Group rows with second level step 4

Result:

Group rows with second level step 5jpg

You should notice that excel created another bar to the right of the initial bar that was created when we did the outer group. This is to indicate that it is a sub level to the outer group. Repeat the process above for each inner level and you should have this:

Group rows with second level step 6

Using Keyboard Shortcuts to Group Rows

To save a bit of time, we can use keyboard shortcuts instead of always navigating to Data tab > Outline > Group and clicking on Group. This shortcut should replace the just stated process.

Shift +ALT +Right Arrow // This replaces clicking the group button on the ribbon

Collapse or Expand Outlines to a specific level

Still on the same example, but now let’s add more levels to it. We would include a subtotal row for the two booking markets we are treating. Highlight the intermediate summary row and detail and go through the grouping process as discussed in the previous headings

Grouping rows Grand Total

Now we have four levels, so we can begin with this section:

Grouping rows Grand Total 2

When you group rows in excel, you get an outline number at the top left corner of your worksheet. These numbers are clickable buttons, and can be used to expand or collapse grouped rows. It works this way, the higher the number at the top left corner, the higher the amount of information showed when clicked and the lower the number at the top left corner, the lower the amount of information showed when clicked.

In our example, we have four outline levels, let’s quickly explain how it works.

  • Level 1 displays the Grand Total only, collapsing all other rows
  • Level 2 displays shows the Grand Total and Booking Market totals
  • Level 3 displays the Grand Total, Booking Market totals and Trade Totals
  • Level 4 displays all the rows

Let’s see how our excel sheet would look when we click on level 3

Expand rows Capt

Just as we said above, you can see the Grand Total, Booking Market Totals and Trade Totals.

To expand or collapse, you can also click the side buttons on the rows. For example, clicking on the plus (+) button on row 5 would expand Europe total under the UK booking market.

Expanding rows with buttons

To collapse intermediate rows to row 5, all we need to do is to click the minus (-) button on row 5 and all grouped information before row 5 are collapsed.

Collapse with button Step 1

Result:

Collapse with button Step 2

Ungrouping Rows in Excel

You can ungroup certain rows in excel and keep the remaining outline. To ungroup rows, just follow these steps.

Step 1: Select the rows you want to ungroup. Let’s select Europe total under the UK booking market (Rows 1 to 4)

Ungroup rows step 1 1

Step 2: Navigate to Data tab > Outline > Ungroup and click on Ungroup. You can also use the shortcut below:

Shift +ALT +Left Arrow
Ungroup rows step 2 1

Step 3: Click on Ok in the selection box that pops out

Ungroup rows step 3 1

Result:

Ungroup rows step 4

Grouping Rows Through Copying & Pasting Formats

This method can save you a lot of time if you have uniform data that need to be grouped. For example, data for the UK and North America are pretty much the same, so when we group information for the UK booking market, we should be able to copy the format and paste for our North America Booking Market. Let’s go through the process.

Step 1: After grouping one data set (example is the UK booking market), highlight the rows and copy (Ctrl + C)

Group by Format

Step 2: After copying, proceed to highlight all rows for North America booking market like you did for the UK booking market.

Group by Format 2

Step 3: Then click the following combination: ALT + E + S + T

Group by Format 3 2

Step 4: Press enter or click on OK and you should have the result below:

Group by Format 4

Avoid Hiding Rows, Group Instead

Before we close out on this topic, I would just like to touch on something very important which is for you to avoid hiding rows. When working on a model or analysis, there are lot of times you would have a row (or two) that you do not want to show in your presentation but is vital to the other parts of the model, so you result into hiding said row. Yes, I am guilty of this but this is far from modelling best practices. Rather than hiding the rows, group and collapse them. This way, those using or reviewing your model wont miss rows that may be very important for them to understanding the model

That’s all for this post. I hope you were able to learn a thing or two from it. Cheers!