Sửa lỗi cannot sort a table containing merged cells năm 2024

Clicking a third time, I get the "Can't sort with merged cell" message. What actually happens on the third click is that the table is returned to the default sort.

However, it does look like there is a sort bug on strings from my experience. It looks like sorting only applies to the first word in a string

When you sort a range in a Microsoft Excel worksheet, Excel does not sort the range. Additionally, you may receive the following error message:

This operation requires the merged cells to be identically sized.

Cause

This issue might occur if you sort a range of cells, and if the following conditions are true:

  • You previously merged some of the cells, but not all of the cells in the sort range.
  • You previously merged all of the cells in the sort range and the cells are not all the same size.

Workaround

To work around this issue, split all the merged cells in the range, or merge all the cells in the range so that the merged cells are the same size. Each merged cell in the range must occupy the same number of rows and columns as the other merged cells in the range.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

You may receive an error message when you sort a range that contains merged cells in Excel

  • Article
  • 07/21/2022
  • Applies to: Excel for Microsoft 365, Excel 2019, Excel 2016, Excel 2013, Excel 2010, Excel 2007

In this article

Symptoms

When you sort a range in a Microsoft Excel worksheet, Excel does not sort the range. Additionally, you may receive the following error message:

This operation requires the merged cells to be identically sized.

Cause

This issue might occur if you sort a range of cells, and if the following conditions are true:

  • You previously merged some of the cells, but not all of the cells in the sort range.
  • You previously merged all of the cells in the sort range and the cells are not all the same size.

Workaround

To work around this issue, split all the merged cells in the range, or merge all the cells in the range so that the merged cells are the same size. Each merged cell in the range must occupy the same number of rows and columns as the other merged cells in the range.

General solution

  1. Select the entire range you want to sort.
  2. In the Alignment group on the Home tab, select the Alignment dialog box launcher.
  3. Select the Alignment tab, and then clear the Merge cells check box.
  4. Select OK.

Note

This can alter the layout of the data in the range.

Example solution

  1. In a worksheet, type the following data:

    A1: B1: Name C1: Value A2: B2: Sue C2: 1 A3: B3: Tom C3: 2

  2. Merge cells A1 and B1, A2 and B2, and A3 and B3. To do this, follow these steps:
    1. Select each pair of cells.
    2. Select the Alignment dialog box launcher in the Alignment group on the Home tab.
    3. Select the Alignment tab, and then select the Merge cells check box.
    4. Select OK. Do not merge cells in column C.
  3. Select cells A1:C3, select Sort & Filter in the Editing group on the Home tab, and then click Custom Sort.

In the Sort box, select "Column C" next to Sort By, and then select OK. You should see the error message as documented above.

Chủ đề