Excel won't sort when the data it is trying to reorder is not a clean, contiguous range, when a filter or merged cell is in the way, or when the cells are formatted as text so numbers and dates sort alphabetically instead of numerically. The fastest fix is to select the entire data block including headers, remove any merged cells, clear filters, and use Data > Sort with "My data has headers" ticked. If that still fails, check for hidden rows, blank rows splitting the range, and text-formatted numbers. The steps below walk through each cause in the order that resolves most cases.
What You'll Need
- Excel for Windows, Mac, or the web version (menu labels can differ slightly by version, device, and region)
- A backup copy of the sheet if the data matters — sorting overwrites cell positions and cannot be undone after you save and close
- Your data in a single contiguous block with one header row
Step-by-Step
- Save a copy first. Use File > Save As and give the workbook a new name, or press Ctrl+Z (Cmd+Z on Mac) immediately if a sort goes wrong. Sorting rearranges the actual cell contents, so a backup is the only reliable way back.
- Remove merged cells. Select the whole data range, then on the Home tab open Merge & Center and choose Unmerge Cells. Merged cells are the single most common reason Excel refuses to sort or sorts only part of the data. If you need the look of merged cells, use Center Across Selection in Format Cells > Alignment instead.
- Clear any active filter. Go to the Data tab and click Clear (in the Sort & Filter group) to remove filters, then reapply them after sorting. A filter that hides rows can make Excel sort only the visible ones, leaving the rest in place.
- Unhide rows and columns. Select the whole sheet with Ctrl+A (Cmd+A on Mac), then right-click a row or column header and choose Unhide. Hidden rows inside a range can cause Excel to sort only the visible subset.
- Select the entire block, not one column. Click any cell inside the data and press Ctrl+A (Cmd+A on Mac) once. If Excel selects only the current region, that is fine — but if your data has blank rows or columns splitting it, select the full intended range manually by dragging from the top-left to the bottom-right cell.
- Open the Sort dialog. On the Data tab click Sort (not the A–Z or Z–A quick buttons). In the dialog, tick "My data has headers" so the header row stays at the top instead of being sorted into the data.
- Choose the column and order. In the Sort by dropdown pick the column you want to order by, set Sort On to Values, and choose A to Z or Z to A (or Smallest to Largest for numbers and dates). Add levels with Add Level if you need a secondary sort, such as sorting by department and then by last name.
- Click OK and check the result. Confirm that the header row is still at the top and that every row moved together. If a single column sorted independently, you selected only that column — undo with Ctrl+Z and repeat from step 5 with the full range selected.
- Fix text-formatted numbers or dates if they sort wrongly. If 10 sorts before 2, the cells are stored as text. Select the column, open Data > Text to Columns, click Finish on the first screen, and Excel converts the values to real numbers or dates. Alternatively, multiply the range by 1 using Paste Special, or use VALUE() in a helper column.
- Remove leading spaces and stray characters. Use Find & Replace (Ctrl+H) to replace double spaces with single spaces and to remove leading apostrophes. A leading apostrophe forces text format and will break numeric sorting.
Common Mistakes
- Selecting a single column before clicking A–Z, which sorts that column alone and scrambles the rows relative to each other.
- Forgetting to tick "My data has headers," so the header text gets sorted into the middle of the data.
- Leaving a blank row inside the range — Excel treats everything below the blank as a separate block and sorts only the top part.
- Sorting a range that contains merged cells, which Excel either refuses or handles unpredictably.
- Assuming a sort is permanent and skipping the backup; once you save and close, Ctrl+Z no longer helps.
- Sorting dates that are actually text (for example, typed as 01/02/2024 with a leading apostrophe), which orders them alphabetically rather than chronologically.
Tips
- Convert your range to a Table with Ctrl+T (Cmd+T on Mac). Tables expand automatically, keep headers in place, and sort more reliably than loose ranges.
- Use a helper column with a formula such as =TRIM(A2) or =VALUE(A2) to clean values before sorting, then paste the results back as values.
- For custom orders (Small, Medium, Large), use Sort > Order > Custom List rather than typing a manual sequence.
- If you only need to view data in order without changing the sheet, apply a filter and use the filter's own sort options instead of the main Sort dialog.
- Keep one header row only. Two header rows confuse the "My data has headers" option and usually leave a stray row in the sorted data.
Troubleshooting
Excel says "This operation requires the merged cells to be identically sized." Unmerge every merged cell in the range, sort, then reapply any formatting you need using Center Across Selection.
The Sort button is greyed out. You are likely in a protected sheet or editing a cell. Go to Review > Unprotect Sheet (you will need the password), or press Esc to leave edit mode.
Only part of the data sorted. Undo, then check for blank rows or columns inside the range, hidden rows, or a filter that is hiding rows. Select the full block manually and sort again.
Numbers sort as 1, 10, 2. The column is text. Use Data > Text to Columns and click Finish, or convert with Paste Special > Multiply by 1. Recheck that no leading apostrophes remain.
Dates sort wrongly or appear as numbers. The cells may be text or stored as serial numbers with the wrong format. Apply a Date format from Format Cells > Number, and convert text dates with Text to Columns.
Sorting on the web version behaves differently. Excel for the web has fewer sort options than the desktop app. If a custom list or multi-level sort is unavailable, open the file in the desktop app.
If that did not work, copy the data into a brand-new sheet using Paste Special > Values only, rebuild a single header row, and sort there. This removes hidden formatting, merged cells, and stray filters in one move. If the workbook still misbehaves, close and reopen Excel, and check for pending updates in your Microsoft 365 account.
Frequently Asked Questions
Why does Excel sort only one column?
Because only that column was selected when you clicked A–Z or Z–A. Undo, select the whole data block including headers, then use Data > Sort so all rows move together.
Why won't Excel sort my dates correctly?
The dates are stored as text. Convert them with Data > Text to Columns (click Finish) or by applying a real Date format, then sort again.
Can I sort without changing the original order?
Not in place. Sorting rearranges the cells themselves. Keep a backup copy, or add a numbered helper column first so you can restore the original order by sorting on that number.
Why is the Sort option greyed out?
The sheet is probably protected, or you are editing inside a cell. Press Esc, then unprotect the sheet from the Review tab if you have the password.
Does sorting work the same on Mac and the web?
The core Data > Sort dialog is similar, but the web version offers fewer options. For custom lists and multi-level sorts, use the desktop app on Windows or Mac.
How do I sort by last name when the full name is in one column?
Split the name first with Data > Text to Columns using Space as the delimiter, or add a helper column with a formula that extracts the surname, then sort on that column.