How to Sort Data in Excel Without Moving the Header

Formulas & functions · Updated November 20, 2026

To sort Excel data without moving its header, select a cell in the list, choose Data > Sort, and make sure My data has headers is checked before sorting. Excel will keep the heading row at the top and reorder the records beneath it. For a formatted Excel table, you can instead use the sort arrow in the column heading.

Before you start, check that each row is one complete record and that the columns you want to keep together are included in the sort. Sorting changes row order; it does not pin a heading on screen while you scroll. If you want the heading to remain visible farther down the worksheet, freeze the top row as well.

What You’ll Need

  • An Excel worksheet with a heading row, such as Name, Date, or Amount, and at least one row of data.
  • A complete, rectangular data range. Include every related column so values from one record stay together.
  • Permission to edit the worksheet. A protected sheet may prevent sorting.

Step-by-Step

  1. Check the layout. Confirm that the first row of the list contains labels and that each row below it contains one record. Look for blank rows or columns inside the list, merged cells, and separate notes immediately beside the data. These can affect which cells Excel recognizes as the sort range. If the data sits beside unrelated information, plan to select just the data range rather than relying on automatic selection.
  2. Select the list. Click any cell within the data, including a heading or a record. Excel usually detects a connected block of data automatically. To be precise, drag across the full range, from the first heading through the last row and column. For example, if headings are in A1:D1 and records run through row 50, select A1:D50. Keep all columns that belong to each record in the selection.
  3. Open the Sort dialog. On the Windows ribbon, choose Data > Sort. Do not choose a single-column sort command if you need to set the heading option or use several sort criteria. If you selected only one column and Excel asks whether to expand the selection, choose Expand the selection so entire records move together, then confirm.
  4. Tell Excel that the first row is a header. In the Sort dialog, check My data has headers. Excel should then show column names in the Sort by list instead of generic labels such as Column A. If your selected range deliberately starts with data and excludes the heading row, leave the box unchecked. The important point is that the setting must match the range you selected.
  5. Choose the column to sort by. Open the Sort by list and select the heading you want to use, such as Date or Last Name. Under Sort On, leave Cell Values for an ordinary text, number, or date sort. Choose an order such as A to Z, Smallest to Largest, or Oldest to Newest, as appropriate to the data.
  6. Add another level if needed. If two or more records have the same value in your first sort column, use Add Level to set a secondary order. For example, sort first by Department and then by Last Name. Arrange the levels in priority order: Excel applies the first level, then uses the next level to order ties. Remove any accidental levels that would give an unexpected result.
  7. Review the options and sort. Confirm that the correct heading appears in each level and that the header option is checked. Then select OK. Excel reorders the selected data rows while leaving the heading row in place. Scan a few records across multiple columns to check that names, dates, and other fields still belong to the same record.
  8. Use heading arrows for a quick sort, if available. If the range already has filter arrows, open the arrow in the heading you want and select an ascending or descending sort. The arrow is part of the filter controls, not a data value, so the heading remains in the header row. For a formatted table, its heading arrows are available by default when the table has a header row.
  9. Freeze the heading if you also need it visible while scrolling. Sorting keeps the heading above the sorted records, but the row can scroll out of view on a long worksheet. To keep row 1 visible, choose View > Freeze Panes > Freeze Top Row. This changes the worksheet view; it does not change the sort order or the data itself.

In Excel for Mac, select the range and use Data > Sort; then set the header option in the dialog. The wording may appear as My list has headers rather than the Windows label. Excel for the web also provides sorting from the Data tab and header arrows for tables, although the ribbon layout can differ slightly. Check the header setting in the sort options before confirming.

Common Mistakes

Leaving the header option unchecked. If the heading is included in the selected range but Excel is told there is no header, it may sort the label into the records. Undo the sort immediately with Ctrl+Z on Windows or Command+Z on Mac, then repeat it with the correct setting. If the heading was not included in the selection, an unchecked option is correct.

Sorting only one column. If you sort a names column without expanding the selection, the names can become separated from their corresponding dates, amounts, or IDs. Choose Expand the selection when prompted, or select the entire data block before opening Sort. Do not choose Continue with the current selection for records that rely on neighboring columns.

Including unrelated cells or omitting part of the list. A note, second table, or empty row can confuse Excel’s automatic range detection. Conversely, selecting only some rows leaves the rest unsorted. Verify the range in advance, especially when the worksheet contains several separate blocks.

Assuming a visible header is frozen. The heading may stay above its records after sorting but still disappear when you scroll down. Use Freeze Top Row if you need it to remain visible. This is separate from identifying the first row as a header in the Sort dialog.

Tips

  • Format a frequently sorted range as a table. Select the data and choose Insert > Table, then confirm My table has headers if Excel asks. A table provides heading arrows and expands as you add adjacent records, which can make repeat sorts easier. Check that the table includes all the columns that belong together.
  • Use the dialog for careful or repeatable sorts. A quick arrow sort is convenient for one column. The Sort dialog is clearer when you need multiple levels, want to verify the header setting, or need to choose a particular order.
  • Check what the sort means for your data. Text sorted A to Z is ordered alphabetically, while dates and numbers should sort chronologically or numerically. If numbers appear in an unexpected order, some cells may be stored as text. Correct the underlying values before relying on the sort.
  • Keep one header row. Use short, distinct labels in a single row. Blank heading cells and duplicate labels make it harder to select the right field in the Sort dialog and can make a table less clear.
  • Save before sorting a large or important list. Sorting is reversible with Undo until other actions replace the undo history, but saving first provides a simple recovery point if the wrong range or order is used.

Troubleshooting

The heading moved into the data. Undo right away using Ctrl+Z on Windows or Command+Z on Mac. Select the full range again, open Data > Sort, and check the header option. If you cannot undo because you have made later changes, restore the original heading and inspect the records carefully before sorting again.

Values from different records no longer match. Undo immediately if possible. Repeat the sort on the full rectangular range, including all related columns, and choose Expand the selection if Excel prompts you. If the data contains blank rows or columns, select the intended range explicitly so Excel does not stop at a gap.

The Sort by list shows Column A or Column B. This usually means Excel does not recognize the first selected row as a header, or the header row was left out. Check the range boundaries and the header checkbox. If headings are included, enable the header option; if they are not included, select the range again to include them or sort the data-only range with the option off.

The sort order looks wrong. Check that you selected the intended heading and order. Dates or numbers stored as text can sort unexpectedly, and cells with leading spaces may appear out of place in a text sort. Correct inconsistent cell contents, then sort again. Also check for a secondary sort level that is changing the order of records with matching values.

Excel will not sort the range. Look for merged cells within the selected range, which can interfere with sorting, and unmerge them if appropriate. Check whether the worksheet is protected and whether you have permission to sort. If filter arrows or a table are already in use, try sorting from the relevant heading arrow or use the Sort dialog after selecting the complete table.

Frequently Asked Questions

Can I sort data without selecting the header row?

Yes. Select only the data rows and leave My data has headers unchecked. The heading stays untouched because it is outside the selected range. Make sure the selection includes all related columns and every record you want sorted.

Why does Excel sort my header along with the records?

Usually the heading was included in the selected range while the header option was off. Undo the sort, select the full list, and check the header option in the Sort dialog. If you intentionally excluded the heading, leave that option off.

Will the header stay visible when I scroll?

Not automatically. A sort keeps the heading above the sorted data, but scrolling can move it off screen. Choose View > Freeze Panes > Freeze Top Row to keep the first worksheet row visible as you scroll.

Can I sort by more than one column without moving the header?

Yes. Open Data > Sort, check the header option, choose the first column, and select Add Level for additional columns. Excel keeps the header in place and uses later levels to order records that tie on earlier levels.

Does sorting a table move its heading?

No. Sorting with a table’s heading arrow reorders the table records while keeping the heading row at the top. If you use the Sort dialog instead, confirm that the selected range includes the table and that Excel recognizes its headings.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.