Keep Rows Together During Sort in Excel & Google Sheets

This tutorial demonstrates how to keep rows together during a sort in Excel and Google Sheets.

 

sort keep rows together 1

 

Sort and Keep Rows Together

When sorting data by a column in Excel, you must expand the selection to keep rows together. In this example, you have data in Columns B–G, and you want to sort it by Total Sales (Column G) from largest to smallest.

 

sort initial data 1

 

  1. Select Column G (click on the letter G in the column heading). Then in the Ribbon, go to Home > Sort & Filter > Sort Largest to Smallest.

 

sort data excel 1

 

  1. In the Sort Warning window, select Expand the selection, and click Sort.

 

sort expand selection

 

Along with Column G, the rest of the columns are also sorted, so all rows are kept together. This technique works for any sort, including sorting by date or sorting alphabetically.

 

sort keep rows together 1

 

Note: When you’re working with a table or filtered range, all rows are kept together automatically, and there is no need to expand the selection.

Sort and Keep Rows Together in Google Sheets

  1. Select the data range you want to sort (B2:G9), and go to Data > Sort range.

 

google sheets sort range 1

 

  1. In the pop-up window, check Data has header row, choose Total Sales under the Sort by menu, select Z → A, and click Sort.

 

google sheets sort range 2

 

Now the data range is sorted by descending Total Sales, with all rows kept together.

 

google sheets sort range 3a