When Excel will not sort A to Z properly, the usual cause is that your values are stored as text rather than numbers, or that a hidden space, apostrophe or inconsistent case is confusing the sort order. Excel sorts text alphabetically but character by character, so "apple" and "Apple" land in different places, " Item 2" sorts before "Item 10" because of the leading space, and numbers stored as text sort as 1, 10, 2 instead of 1, 2, 10. The fix is to clean the underlying values, then reapply the sort. Nothing is deleted if you follow the steps below, but you should still copy your sheet before large edits.

What You'll Need

  • A copy of your workbook, so you can experiment without risk.
  • Excel on desktop (Windows or Mac) for the cleaning tools described here. Excel for the web and the mobile apps have fewer options, and cell-by-cell cleanup is easier on desktop.
  • A spare column, so you can clean values without overwriting the originals.

Step-by-Step

  1. Select the whole data range, not one column. Click any single cell inside your table, then press Ctrl+A (Cmd+A on Mac) to select the current region, or press Ctrl+T (Cmd+T) to convert the range to a table so Excel keeps rows together. Sorting only one column is the single most common reason rows get scrambled, and it is a different problem from the sort order itself.
  2. Check for a header row. In the Sort dialog choose whether your data has headers. If Excel treats your header as data, the word "Name" or "City" gets sorted into the list and pushes real entries out of order. The setting lives in the Sort dialog under the checkbox labelled "My data has headers" (wording may differ slightly by version).
  3. Look for leading or trailing spaces. Text with a leading space sorts before everything else. Type =LEN(A2) next to a cell and compare it to =LEN(TRIM(A2)). If the numbers differ, spaces are hiding in the cell. In a spare column enter =TRIM(A2), fill it down, copy the result, then use Paste Special > Values over the original column.
  4. Remove invisible non-breaking spaces. Values copied from web pages often contain a non-breaking space (character 160) that TRIM does not remove. Clear it with =TRIM(SUBSTITUTE(A2,CHAR(160)," ")). Both TRIM and SUBSTITUTE exist in all current Excel versions.
  5. Strip stray apostrophes and stray characters. A leading apostrophe in a cell marks content as text but does not display, so it will not be obvious. Look at the formula bar rather than the cell. If a whole column of numbers is stored as text, hover over the cell and click the warning icon that appears at the cell's top-left corner, then choose Convert to Number, or use Data > Text to Columns and simply finish the wizard without changing any delimiter.
  6. Make case consistent. Excel's default sort is case-insensitive for letters, so "alpha" and "ALPHA" normally sit together. However, if you have turned on a custom sort or the values contain accented characters, ordering can look odd. Standardise with =PROPER(A2) to get Title Case or =UPPER(A2) / =LOWER(A2) in a helper column, then replace the originals.
  7. Convert the helper column into static values. Select the cleaned column, copy it, right-click the destination, and choose Paste Special > Values. Delete the helper column. A sort cannot use formulas that reference the row they are being sorted on, and errors like #REF! often appear if it tries.
  8. Sort with the dialog, not just the button. Select your range, then go to Data > Sort. Pick the column from the "Sort by" dropdown, set "Sort on" to Cell Values, choose "Order" as A to Z, and confirm. This dialog shows you exactly what Excel is about to do before it happens.
  9. Read the result and check row integrity. Spot-check a few rows on both edges of the list. If data in one column now sits next to unrelated data in another, you immediately know the sort was applied to a partial range; undo with Ctrl+Z (Cmd+Z) and start again from a full-range selection.

Common Mistakes

  • Sorting a single column. This reorders that column alone and severs the link to all its neighbouring data. Always sort the whole table.
  • Numbers stored as text. They sort as strings, so 1, 10, 100, 2 comes out in that order. Convert to real numbers first.
  • Mixing text and numbers in one column. Excel ranks numbers before text, so a column of mixed types will not come out as a single clean alphabet.
  • Unnoticed merged cells. Merged cells block a sort with an error or produce a scrambled result. Unmerge the range before sorting.
  • Forgetting filters. If AutoFilter is on, Excel may sort only the visible rows depending on how the range is selected. Clear filters first.
  • Sorting a formatted table with totals inside it. Keep the totals row outside your sort range, or mark it as a total row in a table.

Tips

  • Keep a raw-data tab and do all cleaning in a separate copy. It makes recovery trivial.
  • Use a filter dropdown to spot values that begin with a space or unusual character.
  • Custom lists can make sorting match your own order, for example days of the week or priority levels, through Data > Sort > Order > Custom List.
  • If you need repeatable, formula-free sorting, Power Query can load, clean and sort a table and refresh whenever the source changes.
  • Widen a column and use View or the formula bar to check exactly what a cell contains; visual inspection of the cell grid hides leading spaces.

Troubleshooting

Excel shows an error about merged cells or protected sheets. Unmerge the offending range, or go to Review and unprotect the sheet if you have the password. Sorting is blocked on protected sheets by design.

The sort runs but the order still looks wrong. Re-check for leading spaces and non-breaking spaces, then confirm all values are the same type. A quick test: type a new clean value beside a problematic one and see whether it sorts correctly.

Rows become mismatched after sorting. Press Ctrl+Z straight away. Then reselect the entire contiguous range before sorting again.

Text goes to the bottom of the list. This usually means the cells are blank or contain errors like #N/A. Find them with Go To Special > Constants or filter the column for blanks and errors, correct them, then sort.

Nothing happens when you click the sort button. Check that you are sorting a range and not an individual cell in a pivot table, and that the workbook is not read-only. Save a copy and reopen if the file was opened from email or a network share.

Frequently Asked Questions

Why does Excel sort 10 before 2?

Those values are stored as text. Convert the column to numbers via the warning icon or Text to Columns, then sort again.

Why does a name appear at the wrong place in the list?

A hidden leading space, apostrophe or accented character is usually responsible. Use TRIM and SUBSTITUTE to clean the value and check the formula bar.

Does sorting A to Z affect formulas?

Relative references move with their rows, so a well-built table sorts fine. Absolute references and formulas pointing at fixed cell addresses can break, which is why converting to a table and using structured references avoids trouble.

Can I sort case-sensitively?

Standard Excel sorting ignores case. To sort by case you would add a helper column using EXACT or CODE to give each entry a rank, then sort on that column.

Will sorting change my formatting?

Formatting moves with the cell contents when you sort the whole range. Formatting applied by cell address rather than by content may not follow, so check a couple of rows afterwards.