Excel "All the merged cells need to be the same size": fix
Excel shows this when you sort, or sometimes paste or fill, a range where some cells are merged and others are not, or where merged cells span different numbers of rows or columns. Sorting needs a uniform grid. The usual fix is to select the whole range, open Home > Merge & Center (drop-down arrow) > Unmerge Cells, fill the blank cells left behind, then sort again.
What this message means
A merged cell makes several grid cells act as one. Sorting moves whole rows, so every row in the range has to have the same shape. If A2:A4 is merged but B2, B3 and B4 are separate, Excel cannot move row 3 without breaking the merge, so it stops and shows this message. Microsoft's older wording of the same error is "This operation requires the merged cells to be identically sized." Your data is fine. The cause is formatting. Excel does not say which cell is the problem, so the first job is usually finding the merged cells, which are often in a title row, a header row or a grouping column.
Common causes
| Cause | How to tell |
|---|---|
| Some cells in the sort range are merged and others are not | Click a cell in the range. If the Merge & Center button on the Home tab looks pressed, that cell is merged. This often happens with a category column where one label spans several rows while the other columns stay single cells. |
| A merged title or header row is included in the selection | The error shows up when you select whole columns (by clicking the column letters) or press Ctrl+A. Row 1 or 2 has a report title merged across the top, for example A1:F1. |
| Merged cells in the range are different sizes | Every row has merges, but some span 2 rows and others span 3, or some span 2 columns and others span 3. The gridlines inside the merged blocks don't line up. |
| Hidden rows or columns contain merged cells | The merged cells aren't visible. Row numbers or column letters skip (for example 4 jumps to 7), or a filter is on. Find All (see fix 2) lists merged cells you can't see. |
| Pasting or filling into a range with a different merge layout | The message appears when you paste, or drag the fill handle, not when you sort. The source or destination cells are merged in a different shape than the other side. |
How to fix it
1. Sort only the data rows, not the merged title
- Click Cancel on the message.
- Drag to select only the header row and the data below it. Leave out any merged title rows above, and don't click the column letters.
- Go to Home > Sort & Filter > Custom Sort (on Mac: Data > Sort).
- Tick "My data has headers" if the first selected row is a header, choose your column and click OK.
2. Unmerge every cell in the range and fill the blanks
Excel for Microsoft 365, 2024, 2021, 2019, 2016 on Windows and Mac. On Mac, Go To Special is at Edit > Find > Go To > Special, or press Ctrl+G and click Special.
- Select the whole range you want to sort. To clear merges on the entire sheet, click the Select All triangle at the top-left corner of the grid.
- Go to Home, click the drop-down arrow next to Merge & Center (Alignment group) and choose Unmerge Cells. The value stays in the top-left cell and the other cells become blank.
- With the range still selected, go to Home > Find & Select > Go To Special, choose Blanks and click OK.
- Type = then press the Up arrow key, then press Ctrl+Enter (Mac: Control+Return). Every blank now copies the value above it.
- Copy the range and paste it back with Home > Paste > Values so the formulas become plain values.
- Sort the range again.
3. Find hidden merged cells with Find All
Excel desktop for Windows and Mac. Excel for the web has no merged-cell search. Click cells and check whether Merge & Center is highlighted.
- Select the range, or one cell to search the whole sheet.
- Press Ctrl+F (Mac: Cmd+F), or go to Home > Find & Select > Find.
- Click Options, then Format. On the Alignment tab, tick Merge cells and click OK.
- Leave "Find what" empty and click Find All. Every merged cell is listed with its address.
- Click a result and press Ctrl+A (Mac: Cmd+A) to select them all, then close the dialog and go to Home > Merge & Center > Unmerge Cells.
4. Turn off merging through the Format Cells dialog
- Select the entire range you want to sort.
- Press Ctrl+1 (Mac: Cmd+1), or click the small arrow in the corner of the Home > Alignment group.
- On the Alignment tab, clear the Merge cells check box. If it shows a filled square (mixed state), click it until it is empty.
- Click OK, then sort again. This can shift how the layout looks, so check your headings afterwards.
5. Make every merged cell the same size
- Use this only if you need to keep the merged look, for example when each record is two rows tall.
- Decide on one merge shape, for example 2 rows by 1 column.
- Merge the matching cells in every column of the range the same way (for example C1:C2, C3:C4 and so on) so that every row group has the same layout.
- Select the full range, including all merged columns, and run Home > Sort & Filter > Custom Sort.
6. Replace merged headings with Center Across Selection
- Unmerge the title or heading cells first (Home > Merge & Center > Unmerge Cells).
- Select the cells the heading should span, for example A1:F1, with the text in A1.
- Press Ctrl+1 (Mac: Cmd+1) and open the Alignment tab.
- Set Horizontal to Center Across Selection and click OK. The heading looks centred but no cells are merged, so sorting, filtering and pasting keep working.
Next time, skip the search
Crade is an AI assistant for Mac and Windows that sees your screen. When a message like this pops up, ask “what does this mean?” and it explains the exact error in front of you, step by step.
Download CradeStill not fixed?
If Find All with the Merge cells format finds nothing but the error continues, unhide all rows and columns (select all, then right-click a row number and choose Unhide, then do the same for a column letter). Clear any filter with Data > Clear. Then repeat the unmerge on the whole sheet. As a last resort, copy the data, paste it into a new sheet with Paste > Values, and sort there. Pasting values drops all formatting, including merges. If the file is a shared template or comes from a reporting system, ask its owner for a version without merged cells, or contact your IT or Microsoft 365 administrator.
Questions people ask
Can I sort in Excel without unmerging cells?
Only if every cell in the sort range is merged in exactly the same shape, for example every record merged across 2 rows in every column. Otherwise you have to unmerge, or leave the merged title rows out of the selection.
Will unmerging cells delete my data?
No. Unmerging keeps the value in the top-left cell and leaves the other cells blank. Merging is what discards data: when you merge, Excel keeps only the upper-left cell's contents.
Why do I get this error when Excel says there are no merged cells?
The merged cells are usually in hidden rows or columns, or outside the area you searched. Unhide everything, select the whole sheet with the Select All corner, and run Find All with the Merge cells format again, or just apply Unmerge Cells to the whole sheet.
How do I make a heading look merged without merging?
Select the cells, press Ctrl+1 (Mac: Cmd+1), and on the Alignment tab set Horizontal to Center Across Selection. It looks the same as Merge & Center but doesn't block sorting, filtering or copying.
Can an Excel table contain merged cells?
No. Cells inside a table created with Insert > Table can't be merged, which is one reason tables sort reliably. Converting a plain range to a table after unmerging helps prevent this error from coming back.
Sources
- An error message when you sort a range that contains merged cells in Excel (Microsoft Learn)
- Find merged cells (Microsoft Support)
- Merge and unmerge cells (Microsoft Support)
- "All the merged cells need to be the same size" during a Custom Sort (Microsoft Tech Community)
- Excel #CALC! error: what it means and how to fix it
- Excel can't insert new cells (push non-empty cells off worksheet): fix
- Excel "There are one or more circular references": how to fix
- Excel #DIV/0! error: what it means and how to fix it
- Excel "file format or file extension is not valid": how to fix it
- Excel "file is locked for editing by another user": how to fix it