How to Sort Duplicate Rows Highlighted in Red in Excel
Question details
The user needs a method to group or sort duplicate rows together after they have been highlighted with red cell formatting.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Organizing and reviewing a dataset where duplicate entries have already been identified and marked with red highlights.
- Observed behavior
- Duplicate rows are currently scattered throughout the worksheet and need to be brought together for easier viewing, management, or deletion.
Ensure your dataset has clear column headers and no completely blank rows to prevent sorting errors. If you haven't highlighted the duplicates yet, you will need to apply Conditional Formatting first.
Use Custom Sort by Cell Color
The most straightforward way to group red-highlighted duplicates is to use the Custom Sort feature to arrange rows based on their cell color rather than their text values.
This built-in tool brings all rows containing a specific background color to the top or bottom of your dataset. It requires that your duplicate values already have the red formatting applied.
Click any cell within the column containing the highlighted duplicates, or select your entire data range manually.
Navigate to the Home tab on the ribbon. Click on Sort & Filter in the Editing group, and select Custom Sort from the dropdown menu.
In the Sort dialog box, select your target column under the 'Column' dropdown. Change the 'Sort On' dropdown from Cell Values to 'Cell Color'. Finally, pick the red highlight color under the 'Order' option and choose whether to place it 'On Top' or 'On Bottom', then click OK.

Identify and Sort Duplicates using a COUNTIF Helper Column
If you prefer formula-based sorting or haven't reliably applied color formatting, a helper column can accurately count occurrences and sort duplicates together.
Sort and Manage Duplicates Seamlessly in WPS Spreadsheet
WPS Office offers intuitive tools to highlight, sort, and manage duplicate data exactly like Microsoft Excel. It handles complex datasets effortlessly while offering a clean, user-friendly interface.
- 1. Highlight Duplicate Values: Select your data range, navigate to Home > Conditional Formatting > Highlight Cells Rules, and select 'Duplicate Values' to apply a red fill.
- 2. Open Custom Sort: Go to the Data tab and click the 'Sort' icon to open the advanced sorting dialog box.
- 3. Sort by Cell Color: Select your target column, set 'Sort On' to 'Cell Color', pick the red fill, and click OK to instantly group all duplicates together.

Frequently Asked Questions
Can I sort by multiple cell colors at once?
Yes. In the Custom Sort dialog box, click 'Add Level' to create secondary sorting rules. You can define a hierarchy to sort by red cells first, then yellow cells, and so on.
Why did my Custom Sort mix up my row data?
This happens if you only select a single column instead of the entire dataset before sorting. When prompted, always choose 'Expand the selection' to ensure entire rows stay linked together during the sort.
How do I delete the red duplicate rows after sorting them together?
Once sorted, all red rows will be grouped in one continuous block. Select the row numbers on the far-left side for all the red rows, right-click, and select 'Delete'. Alternatively, you can use the built-in 'Remove Duplicates' tool found on the Data tab.




