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
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:
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.
Related articles:
How to filter comma separated data in Excel?
How to filter exact text in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!