Forum Discussion
How do I group multiple lines such that on Sort of the worksheet, the multiple lines stay together?
Here is the step-by-step guide to grouping rows in Excel to keep them together when sorting the worksheet. This method works in all versions of Excel:
- Select the rows that you want to group. You can do this by either selecting the specific rows or by selecting the first row and holding the Shift key while selecting the last row of the group.
- In the Excel Ribbon, go to the "Data" tab (or "Home" tab in some versions) and locate the "Outline" or "Group" section.
- This will group the selected rows together, and a small plus sign (+) or minus sign (-) will appear next to the first row to indicate that it is grouped. Clicking on the plus sign will collapse the grouped rows, and clicking on the minus sign will expand them.
- Now, when you sort the worksheet, the grouped rows will stay together and move as a unit.
- To ungroup the rows, right-click on one of the grouped rows and choose "Ungroup" or "Ungroup Rows" from the context menu.
Note: When grouping rows in Excel, make sure that the rows you want to group are contiguous (i.e., they are immediately below each other). If they are not contiguous, you may need to move or copy the rows to be adjacent before grouping them.
You can also find the option to group rows on the "Data" tab in the Excel Ribbon. Select the rows you want to group, then click the "Group" button in the "Outline" or "Data Tools" group. Text and steps were edited with the help of AI.
- NikolinoDEJul 05, 2023Gold Contributor
I'm glad I could help with your project.
I wish you continued success with Excel!
If this information helped you, please mark this post as "Correct answer" and/or click on Like button (hand with thumbs up), so that other members can see and benefit from this information later.- Riny_van_EekelenJul 05, 2023Platinum Contributor
"2. Right-click on one of the selected rows and choose "Group" or "Group Rows" from the context menu.
3. This will group the selected rows together, and a small arrow will appear next to the first row to indicate that it is grouped."
Would you mind indicating in which Excel version this works as described? I found feature number 2 in Google Sheets but it comes back with plus and minus signs to indicate grouping. Not an arrow as suggested in point 3.
- NikolinoDEJul 05, 2023Gold ContributorYou are correct, in Excel, when you group rows, a small plus sign (+) or minus sign (-) is displayed to indicate the grouping, not an arrow. The plus sign indicates that the grouped rows are collapsed, and the minus sign indicates that they are expanded. Since it helped the user, I think he discovered this himself. Thanks for the hint.