Excel Not Sorting Correctly? Fix Common Causes

Errors & fixes · Updated November 18, 2026

Excel usually sorts incorrectly because it is sorting only part of a table, treating numbers or dates as text, or interpreting a header as data. Select a cell in the complete dataset, choose Data > Sort, confirm the correct column and order, and make sure My data has headers is selected when the first row contains headings.

Start with the range Excel is sorting

The most important check is whether every related column is included. A row is a record: if a name, date, status, and amount belong together, they must move together. Sorting just the amount column can leave the amounts beside the wrong names, even though the column itself looks perfectly ordered.

  1. Click a cell inside the dataset, rather than selecting just one column.
  2. Open Data > Sort. Check the sort column, the Sort On setting, and the order.
  3. If Excel asks whether to expand the selection, choose Expand the selection to keep each record intact. Choose Continue with the current selection only when you intentionally want to sort that one column independently.
  4. Choose OK and inspect a few complete rows to confirm their values stayed together.

Excel often detects a continuous block of neighboring data automatically, but blank rows or columns can break that block. If a blank row separates part of a list, Excel may treat the data above and below it as separate regions. Remove unintended gaps or explicitly select the full rectangle before sorting. Avoid selecting entire worksheet columns when the list is only a small section of a sheet; that can include unrelated content.

Check headers and sort settings

A header row should remain at the top, not be sorted into the records. In the Sort dialog, select My data has headers if the first row contains labels such as Customer, Date, or Amount. The Sort by list should then show those labels. If the option is unchecked, Excel may treat a heading as an ordinary value; for example, the word Date can appear among the sorted entries.

For a simple sort, use a table’s filter arrow in the relevant column and choose Sort A to Z, Sort Z to A, Smallest to Largest, or Largest to Smallest, as appropriate. For more control, use Data > Sort and check the dialog’s settings before confirming. In Sort On, Cell Values is the usual choice. Cell Color, Font Color, or Conditional Formatting Icon are valid alternatives when you deliberately want visual formatting to determine the order.

When records need more than one ordering rule, add levels in the Sort dialog. For instance, sort first by Department, then by Last Name, then by First Name. This keeps departments grouped while ordering people within each group. A one-column sort cannot produce that same arrangement reliably.

Numbers and dates may be stored as text

Values that look alike on screen may have different underlying types. A true number sorts numerically, while a number stored as text may sort alphabetically. For example, a text sequence can place 100 before 20 because Excel compares the first characters, whereas numeric order places 20 before 100. A mix of text and numbers in the same column can therefore produce a result that appears inconsistent.

Dates can have the same problem. A real Excel date is stored as a serial number and displayed using a date format. A date typed or imported as text may sort by its characters instead of its calendar value. Text such as 04/05/2026 can also be ambiguous: depending on the source and regional settings, it might mean April 5 or May 4. Confirm what the original data represents before converting it.

  • Look for an error-checking indicator or a warning that a number is stored as text. If Excel offers Convert to Number and you have confirmed the value should be numeric, use that option.
  • Check a few suspect values individually. A value aligned differently from nearby values can be a clue, though alignment alone is not proof.
  • For imported data, check the original file, delimiter, and regional date conventions. Re-importing with the correct type or correcting the source can be safer than guessing at a conversion.
  • After conversion, sort again and verify representative values at the beginning, middle, and end of the list.

Do not fix a mixed-type column by changing only its number format. Formatting changes how a value appears; it does not necessarily turn text into a number or a date.

Look for spaces, inconsistent labels, and custom order

Text can contain leading spaces, trailing spaces, or nonprinting characters copied from websites and other systems. Those characters affect alphabetical order even when they are hard to see. For example, a name with a leading space may appear before names beginning with A. Similarly, labels such as North, north, and North followed by a space may look like duplicates while behaving as distinct text values in some comparisons or cleanup tasks.

Inspect suspicious entries in the formula bar and compare them with a known-good value. If the data comes from an external source, clean it at the source when possible, then repeat the sort. Avoid replacing values blindly: a space can be meaningful in some identifiers, and cleaning must not change account numbers or codes that should remain text.

Excel can also use a custom list rather than ordinary alphabetical order. A list of weekdays or months may be sorted in calendar order, and organizations may define their own sequence. In the Sort dialog, inspect the Order setting if the result seems logical but is not A-to-Z. Choose the regular alphabetical or numeric order when that is what you need.

Filters, hidden rows, and tables

A filter changes which records are visible. If a filter is active, sorting the visible results can make it seem that some records have disappeared; they may simply be excluded by the filter. Check the filter arrows for selected values and clear filters when you need to review the complete list. With an Excel table, the header arrows are a convenient way to sort the table while keeping its columns together.

Hidden rows or columns can also make the result confusing because you cannot see every value or record in the displayed range. Unhide relevant rows and columns before checking the outcome, and review any grouped or filtered sections. If the dataset is an Excel table, confirm that all intended records are inside it: records pasted directly below a table may not always be part of the table if there is a blank row or other interruption. Use Table Design to inspect the table and its range if the sort omits recently added data.

Special cases that block or change sorting

Merged cells are a frequent obstacle. Excel may refuse to sort a range containing merged cells of different sizes because the merge structure does not fit the row-by-row movement sorting requires. If possible, unmerge cells in the data area and use alignment or Center Across Selection for appearance instead. Keep merged presentation headings outside the sortable records.

Also check for totals, notes, and subtotals inside the dataset. A total row mixed into ordinary records can move into the middle of a sorted list. Keep totals outside the sortable block, or use a table’s Total Row feature. If a column contains formulas, sort the complete records rather than only the displayed formula results; sorting whole rows preserves the relationship between a formula and its record.

Dynamic-array results are another special case. In Microsoft 365 and Excel 2021 or later, a formula using SORT can return a sorted spill range without rearranging the source data. The spill is calculated output, not a regular editable list, so change the source data or formula rather than trying to sort individual cells inside the spill range. This is useful when you want a sorted view while preserving the original order.

A reliable way to diagnose a bad sort

Suppose a sales list has columns for Region, Representative, Date, and Revenue, but revenue appears out of order. First check whether the sort covered the entire list and whether it used the Revenue column. Then verify that Revenue values are numbers rather than a mixture of numbers and text. If the intended result is grouped by region and ordered by revenue within each region, set two levels: Region first, then Revenue from largest to smallest. Finally, check for a filter that hides some records and confirm that a total row was not included among the sales.

When the result is still surprising, undo the sort immediately with Ctrl+Z on Windows or Command+Z on Mac. Then inspect a small set of source values and redo the operation with a clearly selected range. Undo is useful for a normal sort, but it is not a substitute for a backup when a workbook has complex formulas, linked data, or later edits that you need to preserve.

Prevent sorting trouble next time

  • Use one header row, one record per row, and consistent data types within each column.
  • Keep blank separator rows, merged cells, notes, and totals outside the sortable data block.
  • Convert a well-formed list into an Excel table with Insert > Table. Tables provide filter arrows and generally expand as you add adjacent records.
  • When importing data, check date and number interpretation before sorting, particularly when files come from another country or system.
  • For multi-column ordering, use Data > Sort and add levels instead of repeating single-column sorts in an uncertain order.

Excel for Mac has the same basic sorting workflow: select the data and use the Sort controls on the Data tab, then check the range and header settings. Ribbon placement and dialog appearance can differ slightly by platform and update. In Excel for the web, use the Data tab or a table header’s sort menu; if a command is unavailable for the current selection, open the workbook in the desktop app and check for merged cells or a protected sheet.

Frequently Asked Questions

Why does Excel sort 100 before 20?
Those entries may be stored as text, so Excel is comparing characters rather than numeric values. Convert confirmed numeric text to numbers, check for mixed types, and sort again.

How do I sort a column without separating the rows?
Click a cell in the dataset, then sort that column using its table filter arrow or Data > Sort. If Excel asks, choose Expand the selection so each row’s other values move with it.

Why did my header move when I sorted?
The Sort dialog may not have recognized the header row. Open Data > Sort and select My data has headers, then confirm the column labels and sort order before applying the sort.

Why are some rows missing after I sort?
An active filter may be hiding records, or some rows may be outside the selected range or table. Clear filters, inspect hidden rows, and confirm that the complete dataset is included.

Can I sort a list but keep the original order too?
Yes. Keep the source list unchanged and create a separate sorted view with Excel’s SORT function in Microsoft 365 or Excel 2021 and later. The function returns sorted results elsewhere; it does not rearrange the source records.

Related

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

More in Errors & fixes

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

Spotted an error in this guide? Let us know.