Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in


How to filter data by multiple colors in Excel?

Normally, in Excel, you can quickly filter rows with only one color, but, have you ever considered filtering rows with multiple colors at the same time? This article, I will talk about quick trick for you to deal with this problem.

Filter data by multiple colors with VBA code

Count / sum cells based on background color / font color/ conditional formatting:
Kutools for Excel’s Count by Color can quickly count and sum cells based on background color, font color. With it, you can count and sum by conditional formatting color as well.

arrow blue right bubble Filter data by multiple colors with VBA code

In Excel, there is no direct way for you to filter rows by multiple colors, but, you can create a VBA code to return the color index number of the corresponding row in a new column, and then filter the rows by this helper column.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Extract color index number:

Function GetColor(x As Range) As Integer
GetColor = x.Interior.ColorIndex
End Function

3. And then go back to the worksheet, and enter this formula: =Getcolor(A2)(A2 is the colored cell you want to return its color index number) into a blank cell besides your data, see screenshot:

doc filter by multiple colors 1

4. Then drag the fill handle down to the cells that you want to get the color index, and all the corresponding color index numbers have been extracted as following screenshot shown:

doc filter by multiple colors 2

Tips: If the cells are not filled with background color, it will display a negative number -4142.

5. And then you can filter multiple color rows by using this new helper column, select this helper column, and click Data > Filter, then click the arrow button at the lower right corner of the first cell, in the list box, select the color index number that you want to filter, see screenshot:

doc filter by multiple colors 3

6. Then click OK button, and your selected colors will be filtered out, see screenshot:

doc filter by multiple colors 4

7. At last, you can hide the helper column as you need.

Related articles:

How to filter comma separated data in Excel?

How to filter exact text in Excel?

Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Snigdha Jha · 1 years ago
    This is AMAZING!!
  • To post as a guest, your comment is unpublished.
    towshin · 1 years ago
    tnks brother, bt some colorit can't read and showing same figure
  • To post as a guest, your comment is unpublished.
    Larry · 2 years ago
    Thanks for the great workaround!!
  • To post as a guest, your comment is unpublished.
    Jerry · 2 years ago
    This is brilliant! Thank you very much. It's a pity this isn't stock but your solution is a great workaround.
  • To post as a guest, your comment is unpublished.
    Tina Grezinski · 2 years ago
    What changes to the above would be needed to put in the personal workbook so this function can be used with any spreadsheet and not need to be redone every time it was to be used?

    Thank you for your help! :)