ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Errors & fixes
  3. Excel Sort Not Working? Causes and Quick Fixes

Excel Sort Not Working? Causes and Quick Fixes

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

When Excel sort is not working, the data is usually the problem, not the sort. Numbers or dates stored as text sort in the wrong order, leading spaces push rows to the top, merged cells block the sort, and blank rows stop Excel from selecting the whole table. Clean the column with TRIM and VALUE, unmerge cells, then sort again.

Key takeaways

  • Numbers stored as text sort like words, so 120 comes before 45. Convert them with VALUE or Convert to Number.
  • A leading space sorts before any letter or digit. Remove it with TRIM.
  • Select one cell in the table, not one column, or the rows get scrambled.
  • Merged cells must all be the same size before Excel will sort; usually it's easier to unmerge them.
  • SORTBY with VALUE and TRIM can sort messy data correctly without changing the original.
On this page+
  1. Quick checklist: why is Excel sort not working?
  2. Numbers and dates sort in the wrong order
  3. Spaces and hidden characters push rows to the top
  4. Rows get mixed up or only part of the data sorts
  5. Sort is greyed out or shows a merged cells error
  6. Months or sizes sort alphabetically
  7. Sort messy data with a formula instead
  8. Practise it

When Excel sort is not working, the sort itself is almost never broken. The problem is in the data: numbers stored as text, spaces you can't see, merged cells, or a blank row that cuts the table in two. This guide gives a quick checklist, then the fix for each cause, so you can sort with confidence in a report or a job test.

Quick checklist: why is Excel sort not working?#

Match what you see to the likely cause, then jump to the fix:

What you seeLikely causeQuick fix
120 sorts before 45Numbers stored as textConvert with VALUE or Convert to Number
A few rows stay at the top or bottomLeading spaces or hidden charactersClean with TRIM (and CLEAN)
Dates sort by day or month nameDates stored as textConvert with DATEVALUE
Data in other columns no longer matchesOnly one column was sortedUndo, select one cell, sort again
Only part of the table sortsBlank row or column in the dataRemove the blanks or select the full range
Header row ends up in the middleExcel didn't detect the headerTick My data has headers
Error about merged cellsMerged cells of different sizesUnmerge the cells
Months sort April, August, DecemberAlphabetical sort on textUse a custom list

Numbers and dates sort in the wrong order#

Numbers stored as text sort like words: character by character, from the left. So "120" comes before "45", because 1 comes before 4. Text numbers usually sit on the left of the cell and may show a small green triangle in the corner.

To fix them, select the column, click the warning icon and choose Convert to Number. Or use a helper column with =VALUE(B2) and sort by that. Excel's Sort dialog may also warn that a column contains numbers formatted as text and offer to sort anything that looks like a number as a number. Converting the data is the safer long-term fix. The VALUE function guide and the article on numbers stored as text cover every method.

Dates have the same problem. A text date like "05/10/2026" sorts by its first characters, so all the 01s come first, whatever the month or year. Convert them with DATEVALUE or Text to Columns; the guide to converting text to dates walks through both.

Spaces and hidden characters push rows to the top#

A space sorts before any letter or digit. So " Zara", with a leading space, lands above "Adam" in an A to Z sort, and it looks like the sort failed. Data pasted from websites, PDFs and other systems often brings these spaces with it.

Clean the column in a helper column:

Excel formula
=TRIM(A2)

TRIM removes spaces at the start and end and turns double spaces into single ones. For line breaks and other non-printing characters, use =TRIM(CLEAN(A2)). Then paste the results as values over the original and sort again. Web data sometimes contains a non-breaking space (character 160) that TRIM can't remove; replace it first with SUBSTITUTE(A2,CHAR(160)," "). The TRIM function guide has more examples.

Rows get mixed up or only part of the data sorts#

If you select a single column and sort it, only that column moves. Names end up next to the wrong salaries, and the damage is easy to miss. Excel usually shows a Sort Warning asking whether to expand the selection. Always choose Expand the selection. If you've already sorted the wrong way, undo straight away with Ctrl+Z (Mac: ⌘Z).

The safest habit is to click one cell inside the table and then sort. Excel selects the whole block of data around it. That block stops at the first completely blank row or column, so a blank row in the middle means only the top half gets sorted. Delete the blank rows, or select the full range yourself before sorting.

Two more checks:

  • Header row sorted into the data. In Data > Sort, tick My data has headers.
  • Formulas that change after sorting. Formulas that point at cells in other rows, or at other sheets, can give new answers once the rows move. Paste them as values before sorting if the results must stay put.

Sort is greyed out or shows a merged cells error#

If the Sort buttons are greyed out, check three things. You may still be editing a cell (press Esc). The sheet may be protected (Review > Unprotect Sheet). Or several sheets may be grouped, which shows "Group" in the title bar (right-click a sheet tab > Ungroup Sheets).

If Excel complains that merged cells must all be the same size, the range has merged cells of different sizes. Select the range, click Home > Merge & Center to unmerge, and fill in any blanks. If you only wanted a centred title, use Center Across Selection instead. The article on Merge and Center explains why merged cells cause so much trouble.

Months or sizes sort alphabetically#

When a column holds month names as text, A to Z gives April, August, December. That's correct alphabetical order, just not what you want. Real dates formatted to show the month sort correctly. For text such as Small, Medium, Large, use a custom list: Data > Sort > Order > Custom List. The guide to custom sort orders shows the steps, and how to sort data in Excel covers multi-column sorts.

Sort messy data with a formula instead#

In Excel 2021 and Microsoft 365, SORT and SORTBY return a sorted copy of the data in new cells and leave the original alone. SORTBY can also clean the sort key on the fly, so messy text prices still sort correctly:

AB
1ProductPrice
2Desk lamp" 45"
3Office chair"189 "
4Monitor" 230"
5Keyboard"35"
6Webcam"95 "
7Headset" 120"

The prices are text with stray spaces. A normal Z to A sort on column B puts Webcam first, because "9" is the highest first character. This formula sorts by the real numbers instead:

Excel formula
=SORTBY(A2:A7,VALUE(TRIM(B2:B7)),-1)

TRIM removes the spaces, VALUE turns the text into numbers, and -1 means largest first. The result spills down: Monitor, Office chair, Headset, Webcam, Desk lamp, Keyboard. The SORT function guide covers the simpler SORT, which sorts by a column of the same range.

Practise it#

Sorting and cleaning go together in almost every data task, and job tests often hide text numbers or extra spaces in the data on purpose. Practise the SORT function in a live spreadsheet: you type the formula and it checks it instantly. Then clean data in the cleaning text lesson and fix text numbers in the text and VALUE lesson, or try the exercise on this page first.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

The prices in B2:B7 are text with stray spaces, so a normal sort puts them in the wrong order. In D2, use SORTBY to list the products (A2:A7) by their real price, highest first: sort by VALUE(TRIM(B2:B7)) with -1.

fx
ABCDE
1
Product
Price
By price
2
Desk lamp
45
3
Office chair
189
4
Monitor
230
5
Keyboard
35
6
Webcam
95
7
Headset
120
8
9
10

Tip: SORTBY(what to return, what to sort by, -1). The sort-by part is VALUE(TRIM(B2:B7)).

Practise this in a lesson

LessonSORT: order data with a formulaSort a table by any column, ascending or descending, and combine SORT with FILTER and UNIQUE.LessonCleaning messy textFix stray spaces, random capitals and inconsistent separators in imported data with TRIM, PROPER, UPPER, LOWER and SUBSTITUTE.LessonTEXT and VALUE: numbers to text and backFormat dates and dollar amounts inside sentences with TEXT, and turn digits stored as text into real numbers with VALUE.Function guideSORTSort a range with a formula using Excel's SORT. Sort by any column, highest first, or combined with FILTER. Includes a live exercise.Function guideTRIMClean imported data with Excel's TRIM: strip leading, trailing and double spaces so lookups and counts work. Examples and live practice.Function guideVALUEFix numbers stored as text with Excel's VALUE function, so SUM and lookups work again. Examples, common mistakes and a live practice exercise.

Frequently asked questions

Why is Excel not sorting my numbers correctly?

+

The numbers are probably stored as text, so Excel sorts them character by character: 120 comes before 45 because 1 comes before 4. Convert the column to real numbers with VALUE, or select it and use the Convert to Number option, then sort again.

Why is the Sort button greyed out in Excel?

+

The sheet may be protected, you may be editing a cell, or several sheets may be grouped. Press Esc to leave the cell, unprotect the sheet in the Review tab, or right-click a sheet tab and choose Ungroup Sheets.

Why does Excel say all merged cells need to be the same size?

+

Your range contains merged cells of different sizes, and Excel can't move them row by row. Select the range, click Merge and Center to unmerge, and use Center Across Selection if you only wanted the look.

Why did sorting mix up my data?

+

Only one column was sorted, so its values moved while the other columns stayed put. Undo straight away with Ctrl+Z (Mac: Command+Z). Next time click one cell in the table, or choose Expand the selection when Excel asks.

Why are my dates not sorting in date order?

+

Some or all of the dates are text, so they sort alphabetically. Convert them to real dates with DATEVALUE or Text to Columns, then sort oldest to newest.

Sources

  • Sort data in a range or table - Microsoft Support
  • Convert numbers stored as text to numbers - Microsoft Support
  • SORTBY function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Quick checklist: why is Excel sort not working?
  2. Numbers and dates sort in the wrong order
  3. Spaces and hidden characters push rows to the top
  4. Rows get mixed up or only part of the data sorts
  5. Sort is greyed out or shows a merged cells error
  6. Months or sizes sort alphabetically
  7. Sort messy data with a formula instead
  8. Practise it

Keep reading

Data tools· 6 min read

How to Sort Data in Excel by One or More Columns

To sort data in Excel by one column, click any cell in that column and choose Data > Sort A to Z or Sort Z to A. To sort by several columns, choose Data > Sort, pick the first column, then click Add Level for the next one. Click a single cell first so Excel keeps each row together.

Data tools· 5 min read

Custom Sort in Excel: Sort by Your Own Order

To do a custom sort in Excel, go to Data > Sort, choose the column in Sort by, and set Order to Custom List. Type your order, such as High, Medium, Low, click Add and then OK. Excel sorts the rows in that order instead of alphabetically. With a formula, use =SORTBY(A2:C9,MATCH(B2:B9,E2:E4,0)), where E2:E4 holds the order.

Errors & fixes· 6 min read

Numbers Stored as Text in Excel: Find and Fix

Numbers stored as text look like numbers but Excel treats them as words, so SUM skips them and lookups miss them. You can spot them by left alignment and a small green triangle. To fix them, select the cells, click the warning icon and choose Convert to Number, or use =VALUE(A2) in a helper column.

More on errors & fixes

  • How to Stop Excel Changing Numbers to Dates
  • Excel SUM Showing 0? Causes and Fixes
  • SUMIF Not Working? Common Causes and Fixes
  • "You've Entered Too Many Arguments": How to Fix It
  • #VALUE! Error in Excel: Causes and Fixes
  • VLOOKUP Returning the Wrong Value? Here's Why
All errors & fixes articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free