Fix Excel Merged Cells Error When Sorting a Range
Question details
The user needs to sort a range of data but is blocked by a formatting error related to merged cells.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Attempting to sort a dataset or table chronologically or alphabetically in a spreadsheet.
- Observed behavior
- Excel blocks the sorting operation and displays the prompt: 'To do this, all the merged cells need to be the same size.' This occurs because the selected range contains merged cells with incompatible dimensions.
Before making structural changes, it is highly recommended to visually identify where the merged cells are located within your data range, especially if you are working with a large dataset.
Unmerge Cells Before Sorting
The most direct way to bypass this error is to unmerge the affected cells within your selected data range so that every row and column can be sorted independently.
Excel requires each cell in a sorting range to be structurally identical. When cells of varying sizes are merged, Excel cannot determine how to move the data accurately. By unmerging the dataset, you allow Excel to sort individual cells according to your rules.
Highlight the specific data range or the entire worksheet that you are attempting to sort.
Navigate to the 'Home' tab on the top ribbon. Locate the 'Alignment' group, click the drop-down arrow next to the 'Merge & Center' button, and select 'Unmerge Cells'.
Once all cells are independent, go to the 'Data' tab and click 'Sort' to apply your sorting rules successfully.

Sort Data Without Hassle in WPS Spreadsheet
WPS Office Spreadsheet provides a seamless and user-friendly experience for managing, unmerging, and sorting complex datasets. It perfectly handles structural formatting issues, ensuring your data processing remains smooth and accurate.
- 1. Open Your File in WPS Spreadsheet: Launch WPS Office and open the workbook containing the merged cell sorting error.
- 2. Select the Data: Highlight the rows and columns or the entire worksheet you want to organize.
- 3. Unmerge the Cells: Go to the 'Home' tab, click the drop-down under 'Merge and Center', and choose 'Unmerge Cells'.
- 4. Apply Your Sort Options: Navigate to the 'Data' tab, click 'Sort', and choose your sorting criteria to organize the rows flawlessly.

Frequently Asked Questions
How can I easily find all merged cells in a large Excel sheet?
You can locate merged cells using the Find and Replace dialog. Press Ctrl+F, click 'Options', go to 'Format', select the 'Alignment' tab, and check the 'Merge cells' box. Click 'Find All' to display a list of every merged cell in the sheet.
Can I sort data while keeping some cells merged?
Excel only allows sorting if all merged cells within the selected sort range are exactly the same size. If the merged cells vary in dimension across rows or columns, you must unmerge them first, or entirely exclude those specific rows/columns from your sort range.
What is the best alternative to merging cells to avoid sorting errors?
Instead of merging, use the 'Center Across Selection' feature. Select the adjacent cells you want to center text over, right-click and choose 'Format Cells'. Under the 'Alignment' tab, set the Horizontal alignment to 'Center Across Selection'. This visually centers the text without functionally merging the cells, preventing any sorting errors.
Will unmerging cells delete any of my data?
No, unmerging cells will not delete your data. The text or value that was displayed in the merged cell will simply be placed into the top-leftmost cell of the previously merged range, while the rest of the previously merged cells will become blank.




