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.
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:
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:
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:
6. Then click OK button, and your selected colors will be filtered out, see screenshot:
7. At last, you can hide the helper column as you need.
Excel Productivity Tools
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 1 years agoThis is AMAZING!!
To post as a guest, your comment is unpublished.· 1 years agotnks brother, bt some colorit can't read and showing same figure
To post as a guest, your comment is unpublished.· 2 years agoThanks for the great workaround!!
To post as a guest, your comment is unpublished.· 2 years agoThis 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.· 2 years agoWhat 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! :)