Can Excel Sort by Color? How to Fill Color and use Sort & Filter's Custom Sort

Excel can sort by cell color, font color, cell icon, and values.
  • JD Sartain (PC World (US online))
  • 12 February, 2019 07:17

Can Excel sort by color? Absolutely. In addition to sorting by values, Excel can sort by cell color, font color, and cell icon.

First, you must you must define the colors for your sort columns/fields. For this example, we’ll select colors based on the SALES column.

1. Highlight all the rows with sales from 100 to 500 million. To choose a background color, click Home on the main menu row and go to the Font group. Find the paint-bucket icon that stands for Fill Color, and click the down arrow next to it. A color palette appears, from which you may choose a color by clicking its thumbnail. For our example, we've chosen Yellow from the Standard Colors group.

2. Highlight the next group with sales from 77 to 85 million, then choose Blue.

3. From 60 to 65 million, choose green; for 50 million, choose Orange; choose lavender for 40 to 45 million, and cyan (turquoise) from 30 to 39 million

01 choose colors for each specific range JD Sartain / IDG Worldwide

Choose colors for each specific range

Now that the colors are defined by SALES, you can use them to sort by BOOK, AUTHOR, LANGUAGE, or PUB DATE, and, for example, view authors with sales of Cyan, which denotes the group with sales between 30 and 39 million.

1. Move the cursor anywhere inside the data range, press Ctrl+A to highlight everything.

2. From the Home tab on the main menu, select the Editing group. Click Sort & Filter > Custom Sort and the Sort dialog box opens.

3. If you have headers, be sure to check the box that says: My data has headers.

4. Choose a sort key from the Sort By field box under Column, such as Author.

5. Under Sort On, choose Cell Color from the drop-down list.

6. Under Order, choose the thumbnail for the color by which you wish to sort—in our example, it's cyan. 

7. And, in the last field box, choose On Top, which sorts the selected rows to the top of the spreadsheet (choosing On Bottom sorts the selected rows to the bottom).

8. Next, click the Add Level button, which adds a second sort key to the query.

9. From left to right, choose AUTHOR, Cell Values, A to Z, and click OK.

02 sort spreadsheet range by color first then by author JD Sartain / IDG Worldwide

Sort spreadsheet range by color first, then by AUTHOR

Notice that all the Cyan cells (30 to 39 million in SALES) are sorted to the top of the spreadsheet and then alphabetized by AUTHOR within the Cyan colored cells. The rest of the spreadsheet is sorted by AUTHOR only with all the remaining SALES totals (except 30 to 39 million).

03 cyan cells sorted to the top alphabetized by authors name JD Sartain / IDG Worldwide

Cyan cells sorted to the top alphabetized by AUTHOR’s name

For more samples and detailed instructions regarding sorting by colors, values, and icons, and using conditional formatting, check out these two past articles: How to use Microsoft Excel's conditional formatting, and How to customize Excel conditional formatting.