How to Sort by Color in Excel: Complete Step-by-Step Guide for Cell, Font, and Conditional Formatting Colors

Learn how to sort by color in Excel using cell color, font color, and conditional formatting icons. Step-by-step with shortcuts, tips, and troubleshooting.

Microsoft ExcelBy Katherine LeeMay 20, 202618 min read
How to Sort by Color in Excel: Complete Step-by-Step Guide for Cell, Font, and Conditional Formatting Colors

Learning how to sort by color in Excel transforms a cluttered spreadsheet into an organized, decision-ready report in seconds. Whether you have highlighted overdue invoices in red, flagged top-performing sales reps in green, or used conditional formatting to color-code inventory levels, Excel lets you bring all matching cells to the top of your list with a few clicks. This guide walks through every method, from the built-in Sort dialog to right-click shortcuts, custom multi-level color sorts, and workarounds when the feature appears grayed out on your version.

Sorting by color is one of the most underused features in Microsoft Excel, even though it solves problems that formulas like xlookup excel functions cannot. While VLOOKUP and XLOOKUP retrieve values, sorting by color reorganizes your dataset based on visual cues you have already applied. Accountants use it to surface flagged transactions, project managers use it to prioritize red-status tasks, and HR teams use it to group performance ratings before exporting reports to PowerPoint or PDF.

Excel supports sorting by three distinct color attributes: cell background color, font color, and conditional formatting icon. Each attribute can be sorted independently or layered together in a multi-level sort. For example, you can sort by cell color first to group all red rows together, then by font color to push bold white text to the top within each red group. This layered approach gives you analytical precision that simple alphabetical or numerical sorts cannot deliver on visually-coded datasets.

The feature works in Excel 2010, 2013, 2016, 2019, 2021, Microsoft 365, and Excel for Mac. It also works in Excel for the web with minor interface differences. However, the steps differ slightly depending on whether you used manual highlighting, conditional formatting rules, or imported colors from another workbook. Knowing which color source you applied is the first troubleshooting step if the Sort by Color option does not appear in your menu.

This tutorial covers eight scenarios in depth: sorting a single column by cell color, sorting by font color, sorting by conditional formatting icons, multi-level color sorting, sorting filtered data, sorting Excel tables versus ranges, sorting pivot table fields by color, and using VBA to automate color sorts on large datasets. You will also learn how to handle common errors, such as the Sort by Color option appearing grayed out, missing colors in the dropdown, or sorts that scramble row relationships in adjacent columns.

By the end of this guide, you will have a repeatable workflow for any spreadsheet that uses color-coded data. We will include real screenshots descriptions, keyboard shortcuts, and a downloadable practice file structure you can build yourself. Whether you are preparing a quarterly board report, cleaning a CRM export, or studying for an Excel certification exam, mastering color sorting will save you minutes on every report and prevent the manual row-shuffling errors that plague color-coded workbooks.

Before we dive into the steps, note that sorting by color does not sort numerically within the color group. If you need both color grouping and numerical ordering, you will use a two-level sort, which we cover in section four. We will also explain why some users see the Sort Warning dialog about expanding the selection, and how to choose the correct option to keep related data intact across all columns of your worksheet.

Color Sorting in Excel by the Numbers

🎨16M+Colors SupportedFull RGB palette
📊64Sort Levels AllowedMulti-level sorts
⏱️3Clicks to SortRight-click method
💻2010+Supported VersionsExcel desktop & web
🔄3Color AttributesCell, font, icon
Microsoft Excel - Microsoft Excel certification study resource

Five Ways to Sort by Color in Excel

🖱️

Right-Click Quick Sort

Right-click any colored cell, choose Sort, then Put Selected Cell Color On Top. The fastest method when you only need one color brought to the top of a single column dataset.
📋

Data Tab Sort Dialog

Open the Data tab, click Sort, set Sort On to Cell Color, and pick the color and order. This gives you full control and supports adding multiple sort levels for complex datasets.
🔽

Filter Dropdown Sort

Apply an AutoFilter, click the dropdown arrow on a colored column, choose Sort by Color, then pick the color. Useful when filters are already on the dataset.
🎨

Custom Sort Order

Use Add Level in the Sort dialog to define the exact color hierarchy. Red on top, then yellow, then green simulates a traffic-light priority ordering you can save and reuse.
💻

VBA Macro Sort

Record or write a macro using Range.Sort with SortOn:=xlSortOnCellColor for repeatable sorts on large or recurring reports. Ideal for monthly dashboards and automation workflows.

The quickest way to sort by cell color in Excel is the right-click method. Click any cell in your data range, right-click on a cell with the color you want at the top, hover over Sort in the context menu, and choose Put Selected Cell Color On Top. Excel immediately rearranges the rows so every cell with that color appears at the top, followed by all other cells in their original order. This works for both manually applied colors and conditional formatting colors as long as the conditional rule produces a static fill at the time of the sort.

For more control, use the Data tab method. Select any cell inside your dataset, click Data on the ribbon, and choose Sort. In the Sort dialog, set Column to the column containing your colors, set Sort On to Cell Color, and then pick the specific color from the Order dropdown. The final dropdown lets you choose On Top or On Bottom. Click OK and Excel reorders the entire dataset, keeping adjacent columns aligned with their original rows. This is the safest approach for multi-column data because it prevents accidental row scrambling.

If your data is already filtered, you can also sort by color from the filter dropdown. Click the filter arrow on the column header, hover over Sort by Color, and choose either the cell color or font color you want on top. This menu shows a swatch of every color present in that column, so you can quickly identify which highlighted group to surface. The filter-dropdown sort is identical in result to the Data tab method, just accessed from a different place in the interface.

Sorting by font color follows the same workflow with one change. In the Sort dialog, set Sort On to Font Color instead of Cell Color. Font color sorting is helpful when you have used red text to mark errors or blue text to mark hyperlinks while leaving the cell fill unchanged. You can also combine cell color and font color sorts in a multi-level sort, which we cover later. To see your dataset clearly while sorting, you may want to find duplicates in excel using a filter first.

Sorting by conditional formatting icons works the same way. If you applied an icon set such as red, yellow, and green arrows or traffic lights, set Sort On to Cell Icon in the Sort dialog. Then choose the specific icon you want on top from the Order dropdown. Excel evaluates the icon currently displayed in each cell and reorders rows accordingly. This is the cleanest way to sort dashboards that use icon sets to communicate KPI status without changing underlying numeric values.

One important point: sorting by color is a one-time action, not a persistent rule. If you change the data after sorting, the colors do not automatically re-sort. You must rerun the sort to refresh the order. For dashboards that update from external data sources, consider using a helper column with a formula that returns a numeric rank based on the underlying value the color represents, then sort by that helper column instead. This produces dynamic, refreshable color-equivalent sorting.

Finally, remember that Excel ranges and Excel tables behave slightly differently. In a table, sorting preserves the relationship between all columns automatically. In a plain range, you may see a Sort Warning dialog asking whether to expand the selection. Always choose Expand the selection unless you intentionally want to sort just one column and leave the others in their original row positions. Choosing Continue with current selection without understanding the consequence is the most common cause of scrambled spreadsheets after color sorting.

FREE Excel Basic and Advance Questions and Answers

Practice color sorting, filters, and other essential Excel skills with this free quiz

FREE Excel Formulas Questions and Answers

Test your knowledge of VLOOKUP, INDEX MATCH, and conditional formatting formulas

Cell Color vs Font Color vs Conditional Formatting Sorts

Cell color sorting reorders rows based on the background fill of cells in a chosen column. This is the most common color sort, used when you manually highlight cells with the bucket fill tool or when conditional formatting applies a fill color. The Sort dialog lists every unique fill color present in the column, so you can pick which one floats to the top.

The key advantage is visual clarity. Cell colors are highly visible across screens and printed reports, making them ideal for flagging overdue items, top performers, or priority records. The limitation is that cell colors do not carry semantic meaning to formulas, so you cannot use SUMIF or COUNTIF directly against color without VBA or a Name Manager workaround using GET.CELL.

Excellence Playa Mujeres - Microsoft Excel certification study resource

Should You Sort by Color or Use a Helper Column?

Pros
  • +Fast and intuitive for one-time sorts on visually-coded data
  • +Works directly on existing colors without rebuilding formulas
  • +Supports cell color, font color, and conditional formatting icons
  • +Multi-level sorts allow custom color hierarchies up to 64 levels
  • +Available in all Excel versions from 2010 onward including web
  • +Right-click shortcut makes ad-hoc sorting nearly instant
Cons
  • Not dynamic — sort does not refresh when underlying data changes
  • Cannot be used directly in formulas like SUMIF or COUNTIF
  • Sort Warning dialog can scramble rows if user picks wrong option
  • Colors from imported workbooks may not appear in Order dropdown
  • Conditional formatting colors must render before sort can detect them
  • Manual color highlights are lost when copying to plain text formats

FREE Excel Functions Questions and Answers

Master SORT, SORTBY, FILTER, and other dynamic array functions with practice questions

FREE Excel MCQ Questions and Answers

Multiple choice questions covering sorting, filtering, and data management techniques

Pre-Sort Checklist Before You Sort by Color in Excel

  • Save a backup copy of your workbook in case the sort scrambles relationships
  • Confirm your data has a header row so Excel correctly identifies columns
  • Convert your range to an Excel Table with Ctrl+T for safer multi-column sorts
  • Remove any merged cells, which block sorting and trigger error dialogs
  • Verify conditional formatting rules have rendered before opening the Sort dialog
  • Decide whether you want cell color, font color, or icon-based sorting
  • Choose Expand the selection when the Sort Warning dialog appears
  • Plan your color hierarchy — which color should appear on top and why
  • Document your sort criteria for repeatable monthly or quarterly reports
  • Test the sort on a small sample before applying it to thousands of rows

Freeze the top row first to keep headers visible during long sorts

Before sorting datasets with hundreds of rows, freeze the header row using View then Freeze Panes then Freeze Top Row. This keeps column headers visible as you scroll through the sorted results, making it easy to verify the sort worked correctly. Combined with a color sort, frozen headers turn any spreadsheet into a navigable dashboard you can scan in seconds without losing context.

Multi-level color sorting is where Excel becomes a true analytical tool. Open the Sort dialog from the Data tab and click Add Level to create additional sort criteria that apply within the previous level. For example, your first level might sort cell color with red on top. Your second level might sort the same column by yellow on top. Your third level might sort by green on top. The result is a perfect traffic-light ordering where all reds appear first, then all yellows, then all greens, regardless of the original row order.

You can mix sort types across levels. Level one could sort by cell color, level two by font color, and level three by numeric value within a different column. This is powerful for performance reports where you want to surface red-flagged employees first, then within reds sort alphabetically by name, then within names sort by score descending. Excel allows up to 64 sort levels in a single operation, though in practice three or four levels handle nearly every real-world business need without becoming difficult to maintain.

To save a multi-level sort for reuse, consider recording a macro. Turn on Developer then Record Macro, perform your color sort, and stop recording. Excel generates VBA code you can edit, reassign to a button on the Quick Access Toolbar, or call from other macros. The code uses Range.Sort with the SortOn parameter set to xlSortOnCellColor, xlSortOnFontColor, or xlSortOnIcon. This makes monthly reports repeatable in a single click rather than recreating the sort dialog every period.

Custom sorts also work inside pivot tables, but the process differs slightly. Right-click a pivot field, choose Sort, then More Sort Options, and you can sort the field by manually arranged color groupings. Pivot tables remember the sort order across refreshes, unlike plain ranges. This makes them ideal for color-coded dashboards that update from a database connection or Power Query refresh while preserving your preferred visual ordering across reporting cycles.

One subtle behavior to understand: when you sort by color, Excel groups all cells with that color together but does not sort within the group. If you sort cells with red fill on top, all red cells appear at the top of the dataset in their original relative order. To sort within the color group, add a second sort level on a different criterion such as value, date, or text. This two-level approach is the secret to producing reports that are both visually prioritized and numerically ordered within each priority tier.

If your workbook contains many similar shades of color from different sources, Excel may treat them as distinct entries in the Order dropdown even when they look identical to the eye. This often happens when you copy data between workbooks with different theme colors. To resolve, use Find and Replace with formatting to standardize colors across the column before sorting. Alternatively, build a helper column with a VBA function that returns a numeric code per color, then sort that column for predictable, theme-independent results.

Finally, remember that Excel for Mac and Excel for the web support most color sorting features but with minor interface variations. On Mac, the Sort dialog is accessed through Data then Sort and looks nearly identical to Windows. On Excel for the web, right-click sorting is available but the multi-level Sort dialog has fewer options. For complex multi-level color sorts, open the workbook in the desktop application to access the full feature set. Once sorted, the order persists when the workbook is reopened in the web app.

Excel Spreadsheet - Microsoft Excel certification study resource

Several common errors prevent the Sort by Color feature from working as expected. The most frequent is the Sort by Color option appearing grayed out in the menu. This usually means your selected column contains no formatting variation — every cell has the same color or no color at all. Excel hides the option when there is nothing to sort by. To fix this, verify that at least two distinct colors exist in the column, then reopen the menu. The option will reappear once Excel detects color variation across the selected range of cells.

Another common issue is missing colors in the Order dropdown. If you applied conditional formatting that has not yet rendered, the dropdown will not list the resulting colors. Force a recalculation by pressing F9, then reopen the Sort dialog. The colors should now appear. If they still do not show, the conditional formatting rule may not be producing a static fill, or the rule may be applied to a different column than you intended. Check Home then Conditional Formatting then Manage Rules to verify the rule scope and behavior.

Merged cells also block color sorting. If any cells in the sort range are merged, Excel displays an error stating that the operation requires merged cells to be identically sized. Unmerge the cells using Home then Merge and Center, perform the sort, and then reapply formatting if needed. As a best practice, avoid merged cells in any dataset you plan to sort, filter, or analyze. They cause numerous downstream issues beyond just color sorting, including blocking excellent family dogs level pane locking and disrupting pivot table creation.

Sorts that scramble row relationships across columns indicate you chose Continue with current selection in the Sort Warning dialog. To recover, immediately press Ctrl+Z to undo the sort. If you have already saved and closed the workbook, restore from your backup. To prevent recurrence, always convert your range to an Excel Table with Ctrl+T before sorting. Tables automatically expand the sort selection to include all columns, eliminating the warning dialog and the risk of misaligned data across rows.

If you sort by color in a workbook shared via OneDrive or SharePoint, you may see different colors than your colleagues because of theme settings. Standardize theme colors before sharing by going to Page Layout then Themes and selecting a fixed theme such as Office. This ensures the colors render identically across all devices and users. Alternatively, apply colors using the Standard Colors palette rather than Theme Colors. Standard colors are absolute RGB values that do not change based on theme switching across different installations.

VBA-based sorts can fail if the SortOn parameter conflicts with the cell content type. For example, sorting a column of dates by Cell Color requires the dates to be stored as actual date values, not text. If your dates were imported as text, the sort still works for color grouping but cannot add a numeric secondary sort by date. Convert text dates to real dates using DATEVALUE or Text to Columns before running a multi-level color and date sort programmatically through a recorded macro.

Lastly, if you upgraded from an older Excel version and your color sort behaves differently, check that compatibility mode is off. Save the file as .xlsx rather than .xls, close and reopen the workbook, and verify the title bar no longer shows Compatibility Mode. The full color sorting feature set, including icon-based sorting and 64-level multi-criteria sorts, requires the modern Excel file format. Older .xls files limit you to three sort levels and may not support icon set sorting at all in certain edge cases.

To make color sorting a permanent part of your Excel workflow, set up a few habits that pay off across every report. Always convert raw data to an Excel Table with Ctrl+T before applying colors. Tables auto-expand, support structured references, and eliminate the Sort Warning dialog entirely. Combined with conditional formatting rules tied to data values, this gives you a self-maintaining dataset where colors update automatically and sorts always include all related columns without manual reselection of the entire range.

Standardize on a small palette of meaningful colors across your organization. A common convention is red for critical or overdue, yellow for warning or pending, green for complete or on-track, and gray for inactive or archived. When everyone uses the same color semantics, sorts produce instantly recognizable reports without legend explanations. Document the palette in a shared style guide and pin sample swatches to your workbook templates so new team members onboard quickly without applying inconsistent colors that fragment downstream analysis.

Combine color sorting with named ranges and dynamic array functions where possible. Excel 365 introduced SORT, SORTBY, FILTER, and UNIQUE, which produce live, formula-driven results. While these cannot sort by color directly, you can pair them with a helper column that maps color to a numeric priority code. Then SORTBY references the priority column to produce a continuously updating sorted view. This approach combines the visual power of color with the dynamism of modern Excel formulas. You can also excel definition functions like COUNTUNIQUE to verify your sort produced the expected color distribution.

For collaborative reports, use comments or threaded comments to explain why specific colors were applied. A red cell with a comment such as Customer payment overdue 60 plus days gives readers context without requiring a separate legend tab. When you sort by red on top, the explanatory comments travel with the cells, preserving the analytical narrative. This is especially valuable for monthly board reports where executives skim color-sorted dashboards quickly and need immediate context for prioritized items at the top of each list.

Build a reusable macro library for common color sort patterns. Save macros in your Personal Macro Workbook (PERSONAL.XLSB) so they are available across all open Excel files. Typical macros include Sort by Red Cells on Top, Reset Default Sort, and Apply Priority Color Sort. Assign each macro to a Quick Access Toolbar button with a custom icon. This transforms a multi-step menu navigation into a one-click operation, saving meaningful time on recurring monthly, weekly, or daily reports your team produces.

Test your sorts on a duplicate sheet before applying them to the live workbook. Right-click the sheet tab, choose Move or Copy, check Create a Copy, and run your color sort on the duplicate first. This protects against accidental data scrambling and gives you a side-by-side view of before and after. If the sorted result looks correct, delete the original and rename the copy. If something looks off, you still have the original sheet intact to investigate the issue.

Finally, document your sort logic in the workbook itself, either in a Notes sheet or in a header cell with a comment. Future readers, including your future self six months later, benefit immensely from knowing that the report is sorted red, then yellow, then green by Cell Color on Column G, then alphabetically by Column B. Self-documenting workbooks reduce support requests, prevent misinterpretation, and make handoffs to new analysts seamless. Combined with the techniques in this guide, you now have a complete toolkit for mastering color-based sorting in any Excel scenario you encounter.

FREE Excel Questions and Answers

Comprehensive Excel certification practice test covering sorting, formulas, and data analysis

FREE Excel Trivia Questions and Answers

Fun Excel trivia questions on shortcuts, features, and lesser-known spreadsheet tricks

Excel Questions and Answers

About the Author

Katherine LeeMBA, CPA, PHR, PMP

Business Consultant & Professional Certification Advisor

Wharton School, University of Pennsylvania

Katherine Lee earned her MBA from the Wharton School at the University of Pennsylvania and holds CPA, PHR, and PMP certifications. With a background spanning corporate finance, human resources, and project management, she has coached professionals preparing for CPA, CMA, PHR/SPHR, PMP, and financial services licensing exams.