Yes—when Excel says “To do this, all the merged cells need to be the same size,” it usually means the range you are trying to sort contains merged areas with different dimensions. The most reliable fix is to unmerge cells in the range before sorting; if you must keep the appearance, use consistent merge sizes or a non-merged layout instead.
What the merged-cells error means
Excel treats a merged area as one cell spanning two or more ordinary cells. For example, merging A1:C1 creates one merged area that occupies three columns in row 1. Merging A2:B2 creates a different-sized area. If a sort operation encounters both within its range, Excel may not be able to move the records while preserving those merged shapes, so it displays the size error.
Here, “same size” refers to the merged areas’ cell dimensions—the number of rows and columns they cover—not necessarily the visible width or height of the worksheet cells. Two merged areas that each cover two columns and one row have the same cell dimensions even if their columns have different widths. The message most often appears during sorting, but merged layouts can also complicate other actions that need to rearrange or manipulate a range.
A merge is a presentation feature, not a way to combine the underlying contents of several cells. A merged area has one value, stored in its upper-left cell. This distinction matters when fixing the error: unmerging restores the individual cells, but it does not recreate values that were discarded when the cells were originally merged.
Why sorting conflicts with merged cells
A sort rearranges rows or columns according to values in the selected range. Excel needs to move a predictable rectangular set of cells together so that each record remains intact. Merged areas disrupt that regular grid: a merged cell can span several columns or rows, and its boundaries may not line up with neighboring records. Areas of different dimensions make the layout even less consistent.
Imagine a list with names in column A and departments in column B. If the heading or data area contains a merged A:B cell in one row and a merged A:C cell in another, sorting the range may require Excel to move unlike shapes into positions designed for ordinary cells. Excel cannot safely interpret that arrangement as a conventional list, and it can stop with the merged-cells message.
Even if all merged areas are the same size, merges can still make sorting awkward or prevent a particular operation, depending on the selected range and how the merged areas line up. Making their dimensions match addresses the specific size mismatch, but it does not turn a merged layout into a well-structured sortable table.
Find the merged cells causing the problem
First, note exactly what you selected when the error appeared. If you were sorting a small list, inspect that list and any merged cells included at its edges. If you selected an entire worksheet column or a large block, the problem may be a merge far from the visible rows. Search the relevant worksheet before changing its layout.
In Excel for Microsoft 365 on Windows, you can search for cells with the merged format:
- Press Ctrl+F to open Find and Replace, then select Options if the extra settings are not visible.
- Select Format, choose the Alignment tab, and check Merge cells. Confirm the format settings.
- Use Find All to display matching cells, or Find Next to move through them. Check the search scope and worksheet selection so you know where Excel is looking.
The Find dialog’s format search can help locate merged cells, but it is not a structural audit of every possible issue in a workbook. Check the cells it returns and compare their boundaries with the range you were sorting. On Excel for Mac, press Command+F to open Find; the dialog and available controls can differ slightly by release, so use its Options and Format controls if available. If the format search is not available in your Mac build, inspect the relevant range and use the ribbon’s merge controls to check or unmerge areas.
Unmerge cells and retry the sort
If the cells do not need to remain merged, unmerge them throughout the range you intend to sort. On Windows, select the affected cells and choose Home > Merge & Center > Unmerge Cells. The merge button is a drop-down, so open its arrow if the unmerge command is not immediately visible. In Excel for Mac, select the cells and use the corresponding Merge & Center drop-down on the Home tab; ribbon labels can vary slightly by version.
After unmerging, confirm that the records still make sense. A merged cell’s value is kept in the upper-left cell of the former merged area; unmerging does not copy that value into every newly separate cell. If the former merge covered A2:C2, for instance, its value remains in A2, while B2 and C2 are blank unless they already contained data before the merge. Usually, the next step is to sort only the actual data range, with each record on its own row and a header row kept separate.
If the error persists, inspect the whole selected sort range, not just the cells you first noticed. There may be another merge elsewhere in the selection, or the sort selection may include unrelated formatted areas. Select the data block deliberately, then use Data > Sort. For a simple single-column sort, select a cell in the data and choose the appropriate sort command; when prompted, expand the selection if the other columns belong to the same records.
Preserve information before changing merges
Before unmerging a workbook you did not create, check whether any cells in the merged areas contain information that matters. When multiple populated cells are merged, Excel retains the upper-left cell’s value and removes the other values as part of merging. Unmerging later cannot recover those deleted values. If you are uncertain, save a separate copy of the workbook before changing the layout, or inspect the data in the merged areas before proceeding.
There is a difference between the merge itself and the formatting applied to it. Unmerging separates the cells but generally leaves applicable formatting in place, which can make the worksheet look uneven. You can adjust alignment, borders, and column widths afterward. If the worksheet is shared or used as a report, consider whether the merge is serving a visual purpose before removing it; a copy lets you test the change without risking the original.
Keep the appearance without merging
For a heading that should look centered over several columns but remain sortable, use Center Across Selection rather than Merge & Center. Select the cells the heading should span, open Format Cells with Ctrl+1 on Windows, choose the Alignment tab, and select Center Across Selection in the Horizontal alignment list. On Mac, Command+1 opens Format Cells in many Excel releases; use the Alignment tab there as well. The wording or dialog layout may differ slightly between versions.
This alignment option changes how text is displayed without turning several cells into one merged cell. Put the heading text in the leftmost selected cell and leave the neighboring cells empty for the visual effect. The cells remain separate, which is generally more compatible with sorting, filtering, copying, and selecting rectangular data ranges. Unlike a merge, it does not combine values from multiple cells.
For data records, the better solution is usually not to imitate a merge at all. Keep one field per cell and one record per row. If a label needs to cover several categories, repeat it where appropriate or use a separate heading row outside the sortable data. This structure is easier to sort, filter, convert to an Excel table, and use in formulas.
Merged cells, tables, and worksheet design
Excel tables are designed for consistent rows and columns, and merged cells are not allowed inside a table. If the range needs table features such as filter buttons, structured references, or automatic expansion, remove merges from the data area before creating the table with Insert > Table or Ctrl+T on Windows. On Mac, Command+T commonly opens the Create Table dialog. Confirm that the selected range and header option are correct before accepting.
Merges can still have a place in a worksheet used primarily as a printed form, title page, or carefully arranged report. The problem arises when the same range is also expected to behave like a database or sortable list. Keeping decorative headings outside the data block is a practical compromise: merge a title above the records if needed, but keep the records themselves as an unmerged rectangle with one header per column.
Also distinguish a merged area from text that merely appears to cross cell boundaries. If a cell contains a short heading and adjacent cells are empty, the text may visually extend across them without being merged. That visual overflow does not have the same effect on sorting. Check the Merge & Center control or the Alignment settings before concluding that visible text is a merged cell.
Common mistakes when fixing the error
- Unmerging only the obvious cell: A second merge elsewhere in the selected range can still trigger the message. Search and inspect the full range.
- Sorting the entire worksheet: Large selections may include decorative headings, blank areas, or merged cells unrelated to the records. Select the actual data block instead.
- Assuming unmerge fills every cell: It does not duplicate the original value. The value stays in the former merge’s upper-left cell.
- Re-merging cells to make the layout look right: This can bring the same sorting limitation back. Use Center Across Selection for a heading when appropriate.
- Expecting equal-sized merges to guarantee every sort will work: Matching dimensions may remove this size mismatch, but merges can still conflict with the shape or boundaries of the range being sorted.
Frequently Asked Questions
What does “all the merged cells need to be the same size” mean in Excel?
It means Excel found merged areas of different row-and-column dimensions in the range involved in the operation, most commonly a sort. It is about how many worksheet cells each merged area spans, rather than the displayed pixel dimensions.
How do I fix the merged-cells error when sorting?
Select the range and choose Home > Merge & Center > Unmerge Cells, then sort the records again. Check the whole selected range and make sure each record is laid out in ordinary, separate cells. If the merges must remain, matching their dimensions may help, but it is not as robust as unmerging.
Will unmerging cells delete my data?
Unmerging does not normally erase the value retained in the merged area’s upper-left cell. It also does not fill the other cells with that value. Any contents discarded from other cells when the merge was made cannot be restored by unmerging, so inspect or back up the workbook before changing it.
Can I sort Excel data that contains merged cells?
Sometimes, if the merged areas and selected range are compatible, but merges are a frequent cause of sorting errors and make list operations less dependable. For a sortable list, unmerged cells with one field per column and one record per row are the safer design.
How can I center a heading without merging cells?
Use Center Across Selection in Format Cells > Alignment. Enter the heading in the leftmost cell of the selected span and leave the other cells empty. The heading appears centered across the selection while the cells remain separate.
Related
- Absolute Cell Reference Excel Shortcut: F4 Explained
- Excel Regression Analysis Output: What Each Statistic Means
- Data Analysis in Excel: Methods, Steps, and Examples
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Errors & fixes
- Control Z Not Working in Excel? Fix Undo FastIf Ctrl+Z is not working in Excel, first click a worksheet cell and press Ctrl+Z again; on a…
- Lookup Value Not Working in Excel? Fix the CauseA lookup value usually fails in Excel because the lookup and source values do not match exactly, the…
- Excel Alt+H+O+I Not Working? Fix AutoFit Column WidthIf Excel’s Alt+H+O+I shortcut is not working, press the keys in sequence rather than holding them all down:…
- Excel Not Letting You Type in a Cell? How to Fix ItIf Excel will not let you type in a cell, first check whether the worksheet is protected, the…
- MIN Not Working in Excel? Fix the Formula and DataIf MIN is not working in Excel, first check that the formula points to the cells you intend…
- Why Is AVERAGE Not Working in Excel? Common FixesIf AVERAGE is not working, Excel may not recognize the selected cells as numbers, the formula may point…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.