To sort data in Google Sheets without moving the top row, select the table, choose Data > Sort range > Advanced range sorting options, check “Data has header row,” select the column to sort by, and click Sort. Sheets will keep the header out of the sort and rearrange the rows beneath it.
Sort a range and keep its header
This is the most dependable method when the first row contains labels such as Name, Date, or Total. Selecting the range yourself also helps ensure that every column belonging to each record moves together.
- Select the full table, including the header row and all the records you want to sort. For example, if headers are in row 1 and the table runs through column D and row 40, select A1:D40.
- Open Data > Sort range > Advanced range sorting options.
- Check “Data has header row.” The column choices in the sort dialog should then use your header labels.
- Choose the column you want to sort by and select A to Z or Z to A. For dates and numbers, those options sort from earlier to later or smaller to larger, and in the reverse direction, respectively.
- Click Sort. The header stays at the top of the selected range while the data rows are reordered.
If your table starts somewhere other than cell A1, select its actual range rather than assuming it begins at the top-left corner. For example, a table in C3:F25 should be sorted as C3:F25. This limits the operation to the intended records and avoids pulling unrelated notes or another table into the sort.
What “Data has header row” does
The header-row checkbox tells Sheets to treat the first row of the selected range as labels, not as a record to sort. Without that setting, a range that includes its header may place a label such as “Name” among the names, or move it away from the top. Checking the box also makes it easier to identify the sort column by its label rather than by a column letter.
The setting does not pin the row to the top of the screen, and it does not protect the row from every kind of edit. It applies to the range sort you are setting up. If you select only the data rows and leave the header outside the selection, there is no header inside the range to identify; in that case, sort the selected records by the appropriate column. For a clear, repeatable operation, including the header and checking the box is usually simpler.
Sort with a filter instead
A filter is convenient when you expect to sort or inspect the same table repeatedly. Select the table, including its header, and choose Data > Create a filter. Filter icons appear in the header cells. Open the icon for the column you want and choose Sort A to Z or Sort Z to A. The header remains at the top, and the rows are sorted according to that column.
Filters can also show only rows that meet criteria, such as a particular status or date range. Sorting while a filter is active changes the order of the visible table; it does not mean that hidden rows have been deleted. Review the filter indicators if records appear to be missing. To remove the filter, use Data > Remove filter. If several people need different filter views at the same time, Google Sheets also offers filter views under Data > Filter views; these are distinct from applying an ordinary filter to the sheet.
Sort by more than one column
For records with ties in the first sort column, add a secondary sort column. For example, a class list could be sorted first by Grade and then by Last name, so students in the same grade appear alphabetically. In the advanced range sorting options, check the header setting, choose the primary column, and use “Add another sort column” to add the next criterion. Set the direction for each column, then run the sort.
Order matters: Sheets applies the first sort criterion before the next one. If you sort by Last name first and Grade second, the result will not be grouped by Grade in the same way as sorting by Grade first. Include each column that should determine the order, and confirm the chosen labels before clicking Sort. This is especially useful for inventory lists, schedules, and contact tables where one field alone does not provide a meaningful order.
Sort a whole sheet or just a table?
“Sort range” and “Sort sheet” are different choices. Sort range works on the cells you select, which is appropriate for a defined table. Sort sheet sorts the sheet according to a column and can affect data beyond one selected table. If there are separate blocks of information on the same sheet, sorting the whole sheet can mix rows that were not meant to be part of the same dataset.
When you need to preserve a header, selecting the table and using the range-sort dialog with “Data has header row” checked makes the intended boundary explicit. A filter is another sensible choice for a table with headers. Avoid selecting a single column within a multi-column table and sorting it by itself: that can leave names, dates, and other values on a row paired with the wrong record. Sort the complete table range so each row remains intact.
Prepare the data before sorting
A clean rectangular table sorts more predictably than a sheet containing scattered values. Before sorting, check that each column has one kind of information and that the header is in a single row. Remove accidental blank rows within the table, and make sure the selected range includes all records and all fields that belong together. A blank row or a neighboring note can make it unclear where the data should end, so inspect the selection before running the sort.
- Check dates and numbers. Values that look like dates or numbers but are stored as text may not sort as expected. If a date column sorts alphabetically or a numeric list appears out of order, check the cell values and formatting.
- Look for merged cells. Merged cells in a sort range can interfere with sorting. Unmerge cells in the table if Sheets reports a problem or the range cannot be sorted as intended.
- Keep related fields together. Include columns such as customer, order date, and amount in one selected range, even if only one column determines the order.
- Check formulas and notes. Confirm that the range includes the rows containing the records you want, and that adjacent content is not unintentionally included.
For example, suppose columns A through C contain Customer, Due date, and Status. To see the earliest due dates first, select all three columns for the complete table, include its header, and sort by Due date in ascending order. Sorting column B alone could detach a due date from its customer and status, making the resulting sheet unreliable.
Common sorting problems and fixes
The header moved into the data: Undo immediately with Ctrl+Z on Windows or Chromebook, or Command+Z on a Mac. Then repeat the range sort and check “Data has header row,” or use the filter icon in the header. If you continued editing after the sort, inspect the data carefully before relying on undo, because undo also reverses later actions.
Rows no longer match across columns: This usually happens when only one column was sorted instead of the entire table. Undo if possible, then select the full data range and sort by the desired column. If the sheet has already been edited or shared, restoring the original pairings may require checking version history or another copy; do not guess which values belong together.
The sort order looks wrong: Check whether the cells contain consistent values and whether dates or numbers are stored in a consistent way. Text sorting follows text order, which can differ from numeric or chronological order. Also confirm the chosen direction and sort column. A column containing mixed formats, blank cells, or inconsistent entries can produce results that seem surprising.
Sheets will not sort the range: Check for merged cells and whether the selected range is valid. If you see an error or cannot identify the affected cells, review the table for merged cells and confirm that the selection covers the intended rectangular block. If the sheet is protected or you lack permission to edit it, you may need the owner to allow changes.
Keeping the top row visible while you scroll
Keeping a header out of a sort is different from keeping it visible while scrolling. To pin the first row on screen, choose View > Freeze > 1 row. Freezing does not determine what gets sorted; it only keeps that row visible as you move down the sheet. You can use freezing together with a range sort or filter, but still set up the sort correctly so the header is not treated as a record.
This distinction answers a common point of confusion: a frozen row is not protected from being moved by every operation. Freeze the row for navigation, and use the header-row checkbox or a filter for sorting. If the table’s header is lower down than row 1, select the appropriate number of rows under View > Freeze so the header remains visible, while taking care not to include unrelated rows in the data range.
Frequently Asked Questions
How do I sort in Google Sheets without sorting the first row?
Select the table including its first-row header, open Data > Sort range > Advanced range sorting options, check “Data has header row,” choose the sort column and direction, and click Sort.
Can I keep the top row visible while sorting?
Yes. Choose View > Freeze > 1 row to keep the first row visible while scrolling. Freezing is separate from sorting, so also mark the header row in the sort dialog or sort with a filter.
Why did Google Sheets sort my header?
The selected range may have included the header without the “Data has header row” option checked. Undo with Ctrl+Z or Command+Z if appropriate, then repeat the sort with that box checked.
Can I sort rows alphabetically without mixing up the other columns?
Yes. Select the complete table, not just the column containing the names, and sort by that name column. Sheets will reorder the selected rows together, keeping each row’s fields paired.
Can I sort while a filter is on?
Yes. Open the filter menu in the relevant header and choose a sort direction. If the result looks incomplete, check whether the filter is hiding records and clear or adjust the filter criteria.
Related
- Insert an Electronic Signature in Word
- Insert an E-Signature in Word: Steps and Options
- Insert a Digital Signature in Microsoft Word: Steps
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Delete a Random Page in WordTo delete a random page in Microsoft Word, click anywhere on that page, press Ctrl+G on Windows, enter…
- Add Page Numbers in Word 365: A Clear Step-by-Step GuideTo add page numbers in Word for Microsoft 365, open Insert > Page Number, choose a position and…
- How to Remove a Blocked Sender in Outlook SettingsTo remove a blocked sender in Outlook, open your email account’s junk or blocked-senders settings, find the address…
- Excel Find and Replace Opens File Explorer? Why It HappensNo: in Excel for Microsoft 365 on Windows, Ctrl+H opens the Find and Replace dialog, not File Explorer.…
- How to Remove a Section Break in Word 365 Without FussTo remove a section break in Word 365, show formatting marks, locate the line labeled Section Break, and…
- Google Sheets IF Statement: Syntax and ExamplesIn Google Sheets, an IF statement uses the IF function to test a condition and return one result…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.