Yes. In Excel for Microsoft 365 on Windows, select the entire table, open Data > Sort, set Sort On to Cell Color, and choose the highlighted color and whether it goes on top or bottom. Excel then rearranges the selected records according to the color in the column you choose.
What Sorting by Highlighted Rows Actually Does
Excel does not treat a colored row as a separate kind of record. Its color-based sort looks at the cells in one chosen column, groups rows according to the fill color of those cells, and moves the corresponding rows in the selected range. For example, if you highlighted urgent orders yellow across every column, you can sort by the fill color in the Order ID column and bring the yellow orders together.
The important detail is that the sort is based on a column, not on the visual appearance of an entire row as a whole. If a row is yellow in some cells but not others, Excel needs you to choose which column’s fill color determines that row’s position. If the colors are inconsistent across the row, a helper column is often a more reliable way to define the order.
Sorting is also different from filtering. A sort rearranges records and keeps them visible; a filter hides records that do not match the condition. Use a sort when you want highlighted items grouped while retaining the rest of the list, and a filter when you want to temporarily show only certain colored items.
Sort the Entire Table by Cell Color
Before sorting, make sure the data is a continuous table with a header row and that every related field is included. A customer name, order date, and amount should move together as one record. Selecting just the column containing the colored cells can detach values from the rest of the record.
- Click a cell in the data, or select the full data range, including all columns that belong together. If the range has headers, include them.
- Choose Data > Sort. In the Sort dialog box, check My data has headers if Excel has not already recognized the header row.
- In Sort by, choose the column whose fill color should control the order.
- Set Sort On to Cell Color.
- In Order, choose the color, then choose On Top or On Bottom.
- Choose Add Level if you want to specify where another color should go, and set its column, sort type, color, and position.
- Click OK to apply the sort.
For instance, suppose a task list has columns for Task, Owner, Due Date, and Status, and the Status cells are filled red for overdue tasks and yellow for tasks due soon. Sort by Status, choose Cell Color, and place red on top. Add a second level to place yellow below red. The task names, owners, and dates remain together as Excel rearranges the records.
If Excel asks whether to expand the selection after you selected only one column, choose Expand the selection. That tells Excel to move the adjacent data along with the sorted column. The safer habit is to select the complete table first, so there is less room for a partial sort to scramble a list.
Choose the Right Column and Color Order
When every cell in a highlighted row has the same fill, choosing any consistently colored column in the table can produce the intended grouping. In practice, choose a column that contains the color on every relevant row and is part of the range being sorted. If you highlighted only the Status cell, use Status as the Sort by column; choosing an uncolored Owner column will not identify the highlight.
The Order setting lets you put the selected color at the top or bottom. It does not assign a meaningful priority to all colors automatically. To arrange several colors, add a level for each color and specify its position. For example, place red on top, yellow next, and green below those. Rows with other fills will remain in the remaining part of the sorted list, so inspect the result and use additional levels if you need a precise sequence.
Color sorting groups by fill, not by the reason a person chose that fill. Two yellow cells are treated alike even if one means urgent and the other means awaiting approval. If colors represent categories with different meanings, write those categories in a Status or Priority column and sort by the text or a deliberate priority value instead. That makes the rule clear to other people using the workbook.
When a Helper Column Is the Better Choice
A helper column is useful when row colors are uneven, when color meaning needs to be explicit, or when you want a repeatable order that does not depend on appearance. Add a column such as Priority, enter a value for each record, and sort the whole table by that field. For a simple task list, you might enter 1 for red, 2 for yellow, 3 for green, and 4 for no priority, then sort smallest to largest.
Excel worksheet formulas do not normally provide a built-in way to read a cell’s manually applied fill color. A formula such as a conditional test of the cell value can classify data, but it does not detect an arbitrary color someone painted onto the cell. Therefore, do not expect a standard formula to convert manually highlighted rows into priority numbers automatically.
If the colors come from a consistent business rule, it is usually better to store that rule in the data. For example, if red means a due date has passed, add a Status field or use a formula based on the due date, then sort by the status. Keep the fill as a visual cue. This avoids the problem of a red fill remaining after the underlying condition has changed.
Conditional Formatting, Tables, and Filters
Some colors are applied manually, while others are displayed by conditional formatting. Color-based sorting can be used with cell colors, including colors displayed through conditional formatting in supported Excel versions. However, conditional formatting rules can depend on values, formulas, or position. When a sort changes row positions or recalculates formulas, the displayed colors may change. If the color order matters, verify the result after sorting and check that the rules still express the intended logic.
Excel tables make it easier to keep records together because their headers and data form a defined range. You can use Data > Sort with a table, or use a table header’s filter arrow to access sorting options, including sort by color where available. The full Sort dialog is more useful when you need several color levels or want to combine color with another sort criterion.
Sorting by color does not remove records. To show only one fill color, use the filter arrow for the relevant column and choose Filter by Color, then select the fill. The exact choices depend on the colors present in that column. This is a view of the matching rows, not a permanent deletion; clear the filter to show the other records again.
Common Problems and How to Avoid Them
- Only one column moves: The selected range may not include the complete records. Undo immediately, then select the whole table and sort again.
- The wrong rows move to the top: Check that Sort by names the column where the fill is actually applied. A color elsewhere in the row does not control the sort.
- The header gets mixed into the data: In the Sort dialog, confirm that My data has headers is checked when your selection includes column headings.
- Colors are missing from the Order list: The chosen column may not contain those fills, or the colors may be in another column. Choose the column that holds the relevant color.
- The colors change after sorting: Review conditional formatting rules and any formulas they use. The displayed color may be based on current values rather than being a permanent label.
- Excel will not sort the range: Check for merged cells or inconsistent range structure. Merged cells can interfere with sorting; unmerge them where practical and make sure the data has a consistent layout.
Before making a complicated sort, consider adding an Original Order column with values such as 1, 2, 3, and so on. That gives you a way to restore the initial sequence later by sorting on that column. Undo can reverse a recent sort if no intervening actions have changed the undo history, but an explicit order field is safer when you need a lasting reference.
Windows and Mac Differences
The instructions above use Excel for Microsoft 365 on Windows. Excel for Mac also provides sorting by cell color through its Data sorting controls, although dialog layout and ribbon placement can vary by release. Select the full range, open the Sort controls on the Data tab, and look for the equivalent Sort On, Cell Color, and Order choices. If a command is not visible in the ribbon, use the Sort dialog rather than assuming the feature is unavailable.
Excel for the web has a more limited interface than the desktop application, and available sorting choices can depend on the workbook and current version. If the color-sort option is missing, open the workbook in desktop Excel or use a helper column with explicit priority labels. On either operating system, the core safety rule is the same: sort the complete set of related columns together.
Frequently Asked Questions
Can Excel sort rows by color automatically?
Yes. Use Data > Sort, choose the column that contains the relevant fill, set Sort On to Cell Color, and select the color and position. Excel performs the sort when you apply it; it does not necessarily keep re-sorting every time you change a fill. Apply the sort again when the colors or records change.
Can I sort by more than one highlight color?
Yes. In the Sort dialog, use Add Level to define another color and its top-or-bottom position. Add levels in the order you want Excel to apply them, and check the result if some rows have colors that were not included.
Can I sort by the color of a whole row?
Excel does not evaluate a row as one combined color object. Choose a column where the row’s fill is present consistently. If no single column reliably represents the row color, use a helper field such as Priority instead.
Does sorting by color change or remove the highlighting?
No. A normal sort moves the cells and their formatting with the records; it does not intentionally clear the fill. Conditional formatting may show a different color after values or positions change because its rules are recalculated.
How do I put highlighted rows first without changing the original order?
Before sorting, add an Original Order column and number the records sequentially. Sort by color to group the highlighted rows, then sort by the saved order field when you want to restore the previous sequence. Keep the order field inside the table so it moves with its record.
Related
- Excel Mini Calendar and Date Picker: Your Options
- Excel Min Sec Format: Display Minutes and Seconds
- Small Excel Table: Create, Format, and Use One
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- VLOOKUP and HLOOKUP in Excel: Formulas and UsesIn Excel, VLOOKUP searches down the first column of a table and returns a value from a column…
- Excel UNIQUE Function Not Showing? Causes and FixesIf Excel does not recognize or display UNIQUE, first check your version: the function is available in Microsoft…
- Clear Excel Spreadsheet but Keep Formulas in PlaceTo clear entered values in Excel while keeping formulas, select the cells to clean, choose Home > Find…
- Excel Formula for Quarterly Dates: Examples and TipsTo calculate the first day of the calendar quarter containing a date in A2, use =DATE(YEAR(A2),3*INT((MONTH(A2)-1)/3)+1,1). For example,…
- Excel XLOOKUP Examples for Common Spreadsheet TasksMicrosoft Excel’s XLOOKUP finds a value in one range and returns the corresponding value from another. For example,…
- Excel Functions to Extract Text From Strings: A GuideExcel has several functions for extracting text from a string. Use LEFT, RIGHT, or MID to return characters…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.