Yes. When you sort a range in Excel, any merged cells included in that range must have the same dimensions; otherwise, Excel may stop with the message, “To do this, all the merged cells need to be the same size.” Matching sizes can satisfy that particular restriction, but for dependable sorting, it is usually better to unmerge cells and arrange the data as one record per row.
What the same-size rule means
A merged cell is a single cell area created by joining two or more neighboring cells. For example, merging A1:C1 creates one wide cell occupying three columns. Merging A2:B2 creates a different-sized area occupying two columns. If both merged areas fall inside the range Excel is sorting, their differing dimensions can prevent the sort.
“Same size” refers to the dimensions of the merged areas, not the size of the text, font, or row height. Two areas merged across three columns have matching dimensions if both span the same number of columns and rows. A cell merged across A1:C1 does not match one merged across A2:B2, even if both display a short label.
The condition applies to merged cells that are part of the sort range. A merged title well above the data may not affect a sort that is limited to the records below it. But if the selected range includes the title or other merged areas, Excel evaluates those cells too. Selecting an entire column or a larger block than necessary can therefore bring unrelated merged cells into the operation.
Why merged cells cause sorting problems
Excel sorts a table by rearranging rows or groups of rows according to values in a chosen column. Merged cells do not behave like ordinary individual cells: the merged area has one stored value, while the cells it covers are no longer separate places for data. A merge that spans multiple rows can also cut across the record boundaries that a sort expects to move together.
Consider a list where each row represents one order, with a customer, date, and amount in separate columns. If cells in the customer column are merged vertically across several orders to show that they belong to the same customer, the layout visually groups records but no longer gives every row an independent customer cell. Sorting by amount could separate the visual grouping or make the rows difficult to interpret. The problem is not merely Excel being picky about formatting; the layout conflicts with the idea of sorting complete, consistent records.
There is an important distinction between a merge across columns used as a heading and a merge down rows inside the data. A heading merged across several columns is often outside the actual record range, so it can usually be left alone if it is excluded from the selection. A vertical merge inside the rows being sorted is more disruptive and is a strong reason to redesign the data before sorting.
How to identify the merged cells in the sort range
First check what you are asking Excel to sort. Click a cell in the records and inspect the highlighted range when you open the Sort dialog. Avoid selecting whole columns or including decorative headings unless they belong in the data. On the Windows desktop version of Microsoft 365, use Data > Sort to open the sorting controls; when you start with a cell in a consistent data region, Excel often identifies the adjacent data automatically, but check the range rather than assuming it is right.
To locate merges, select the range you plan to sort and inspect Home > Find & Select > Find. In the Find dialog, choose Options, then Format, and use the alignment settings to search for merged cells if the format search is available in your Excel build. Another practical check is to select suspicious cells and look at Home > Merge & Center: the command or its dropdown can indicate whether the selection contains merged cells. A selection containing a mix of merged and unmerged cells can make the state less obvious, so inspect likely heading and grouping columns separately.
If you are uncertain, make a copy of the sheet or workbook before changing its layout. This is especially useful when the sheet contains carefully arranged report headings or manual formatting. Excel’s Undo can reverse ordinary edits, but a copy gives you a safer reference if several formatting changes follow.
Unmerge cells before sorting
For a list that needs repeated sorting, filtering, or analysis, unmerging is generally the cleanest solution. In Excel for Microsoft 365 on Windows, select the relevant cells, then choose Home > Merge & Center > Unmerge Cells. The button may show a dropdown, so open it to choose Unmerge Cells. The Home tab and merge controls are also available in Excel for Mac, although ribbon arrangement and shortcut behavior can differ slightly by version.
Unmerging restores the underlying grid, but it does not copy the former merged value into every cell. Excel keeps the content in the upper-left cell of the merged area and leaves the other cells blank. If a merged area contained a customer name across three rows, unmerging will not automatically put that name in all three rows. Decide what the blanks should mean before sorting.
A careful workflow is:
- Save a copy of the workbook or duplicate the worksheet.
- Unmerge only the areas that overlap the records you need to sort.
- Fill repeated labels into the rows where each record needs its own value, if appropriate.
- Check that every record has the required fields and that there are no unintended blank rows inside the list.
- Select a cell in the data and use Data > Sort, confirming the selected range and sort column before choosing OK.
Do not fill every formerly merged blank automatically without considering meaning. A blank may indicate that a value is intentionally unknown, or that a category label applies to a group rather than to each record. For sorting a flat list, however, repeating a group label on each row often makes the relationship explicit and avoids ambiguity.
Sort a clean data range correctly
After unmerging, make sure the range is structured as a list: one header row, one record per row, and one type of field per column. For instance, a sales list might have Order ID, Customer, Order Date, and Amount as headers. If you sort by Order Date, select a cell in the list, choose Data > Sort, set Sort by to Order Date, and choose the desired order. Verify that My data has headers is selected when the first row contains labels; otherwise Excel can treat a header as a record.
When sorting one column, keep the related columns in the selection. If Excel asks whether to expand the selection, choose that option when the other columns belong to the same records. Sorting only the Amount column while leaving names and dates in place would mismatch the data. Conversely, do not include a separate note or report title merely because it is nearby.
Excel for the web has sorting commands too, but the ribbon and dialog details can differ from the Windows desktop application. On Mac, use the Data tab’s sort controls; the general principle is the same: include complete records, exclude decorative merged headings, and verify the sort range before applying the operation.
When same-sized merges may still be a poor choice
If every merged area in the selected range has identical dimensions, the size mismatch message may no longer appear. That does not make a merged layout a good structure for sortable data. A merge spanning rows can still represent several records with one shared cell, and sorting may not preserve the visual group in the way a reader expects. Merged cells can also complicate filtering, copying, pasting, and adding new records.
For example, imagine four rows of event registrations, with the event name merged vertically across all four rows and attendee names in the next column. Sorting attendees alphabetically may move rows while the event-name merge remains a single structural block. Even if the merged areas satisfy a size requirement, the layout is not as robust as repeating the event name in each row. A proper table with one event-and-attendee record per row is easier to sort, filter, and summarize.
There are cases where a merge is acceptable: a report title, a printed form, or a presentation-style worksheet that is not intended to be sorted. Keep those presentation elements outside the data range. A useful workbook design is to maintain a plain data sheet for sorting and analysis, then use a separate report sheet for merged headings and visual formatting.
Alternatives to merging cells
If the purpose of merging is visual rather than structural, other formatting choices can often create a similar appearance without combining cells. Select the cells across which a heading should appear, open Format Cells, choose the Alignment tab, and set Horizontal alignment to Center Across Selection where that option is available. This centers text across selected columns while leaving the cells separate. The exact dialog presentation may vary by platform, but it avoids creating one merged cell.
Other options include centering text in a single cell, widening a column, wrapping the heading onto multiple lines, or placing the heading above the sortable range. For category labels that apply to several records, repeat the label on every relevant row or use a separate category column. Repeated values may look less compact, but they make each row self-contained and work better with sorting and filtering.
For polished reports, keep the source data in an unmerged Excel table and build the display separately. Excel tables are designed for structured records and make it easier to filter and sort headers. A presentation sheet can reference or summarize that data without forcing the underlying records into a merged layout.
Common misconceptions and troubleshooting
- “All merged cells in the worksheet must match.” Usually the relevant issue is the merged cells included in the sort range, not every merge on every sheet. Narrow the range to the actual records and try again.
- “Same size means same row height.” The rule concerns how many cells are joined across rows and columns, not whether text looks equally tall or wide.
- “Unmerge fills the value into all cells.” It does not. The content remains in the upper-left cell; other cells in the former merge are blank.
- “I can sort only the column I care about.” Not if other columns contain related details for the same records. Sort complete rows so values stay together.
If the message persists after unmerging the obvious cells, check for a merged area elsewhere in the selected range, including a header row, blank-looking cell, or merged region extending beyond the visible records. Also confirm that the selected range does not include several separate blocks with different layouts. Reducing the selection to the actual list, then checking its headers and boundaries, often reveals the cause.
Frequently Asked Questions
Can I sort Excel data if all merged cells are the same size?
Matching dimensions can satisfy Excel’s specific same-size restriction, but it does not guarantee that the layout will sort meaningfully. For records you need to rearrange, unmerge the data cells and make each row a complete record.
Does sorting affect merged cells outside the selected range?
A merge that is truly outside the sort range should not be part of that sort operation. Check the selection carefully, because including a title or extra columns can bring a merged area into the range unexpectedly.
What happens to text when I unmerge cells?
Excel keeps the content in the upper-left cell of the former merged area. The other cells become separate blank cells, so fill them only if the data meaning calls for it.
Why does Excel say merged cells need to be the same size?
The sort selection contains merged areas with different row or column spans. Remove those merges from the data range, or reduce the range so unrelated merged headings are excluded.
Is Center Across Selection better than Merge & Center?
For a heading that only needs to look centered across several columns, Center Across Selection keeps the underlying cells separate and is generally more compatible with sorting. It is not a substitute for giving every data record its own values.
Related
- Excel Auto Merge Cells With the Same Value? Here’s How
- Excel Add Values to a Dropdown List: Easy Methods
- Excel Adjust Page Breaks for a Better Print Layout
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel MONTH Function Examples: Formulas and TipsExcel’s MONTH function extracts the month number from a date, returning an integer from 1 (January) to 12…
- SUMIF Excel: Sum Cells Containing Specific TextTo sum values when a related cell contains particular text, use SUMIF with asterisks as wildcards. With descriptions…
- Excel MID Function: Extract Text From a CellIf the text you want to extract is in A2, use =MID(A2,5,5) to return five characters starting at…
- Lowercase Names in Excel: Formula, Fill Down, and ReplaceTo lowercase names in Excel, use the LOWER function in a helper column, then fill the formula down.…
- Excel Power Query Filter Rows: Practical Steps and ExamplesTo filter rows in Excel Power Query, open a query in the Power Query Editor, select the filter…
- Excel MID and FIND Functions: How to Extract Text in ExcelWith the text INV-2026-047 in A2, use =MID(A2,FIND("-",A2)+1,4) to extract the year; the result is 2026. MID returns…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.