Excel filter by color

Excel for Microsoft 365 for Mac Excel 2021 for Mac Excel 2019 for Mac Excel 2016 for Mac Excel for Mac 2011 More…Less

Important: Some of the content in this topic may not be applicable to some languages.

You can quickly filter data based on visual criteria, such as font color, cell color, or icon sets. And you can filter whether you have formatted cells, applied cell styles, or used conditional formatting.

  1. In a range of cells or a table column, click a cell that contains the cell color, font color, or icon that you want to filter by.

  2. On the Data tab, click Filter.

    On the Data tab, select Filter

  3. Click the arrow AutoFilter arrow in the column that contains the content that you want to filter.

  4. Under Filter, in the By color pop-up menu, select Cell Color, Font Color, or Cell Icon, and then click the criteria.

    Example of filtering by cell color

  1. In a range of cells or a table column, click a cell that contains the cell color, font color, or icon that you want to filter by.

  2. On the Standard toolbar, click Filter Filter button, standard toolbar.

  3. Click the arrow AutoFilter arrow in the column that contains the content that you want to filter.

  4. Under Filter, in the By color pop-up menu, select Cell Color, Font Color, or Cell Icon, and then click a color.

See Also

Use data bars, color scales, and icon sets to highlight data

Filter a list of data

Apply, create, or remove a cell style

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Watch Video – Filter by Color in Excel (Cell Color or Font Color)

Filtering your data is a common task for many Excel users as a part of their daily work.

Excel already has a well-developed filter functionality that allows you to filter based on many criteria, such as text or number, or dates.

Not many people know that Excel also has an inbuilt filter by color functionality, where you can easily filter your data set based on any pre-existing cell color or font color in your data set.

In this tutorial, I will show you how to quickly filter by color in Excel using the inbuilt filter functionality. I will also cover how to filter based on multiple colors using a simple VBA trick.

Note: Excel allows you to filter your data set based on the cell color as well as the font color of the text/number in the cells. I will cover both of these aspects in this tutorial.

Filter By Color Using the Filter Drop-Down

The best way to filter your data set by color is by applying a filter to your data and then using the drop-down in the headers to filter the cells by color.

Below I have a data set where I have some rows that are highlighted in green color, and I want to filter these records.

Filter by color data set

Filter by Cell Color

Here are the steps to do this:

  1. Select the data (or any cell in the dataset)
  2. Click the Data tab
click the data tab
  1. Click on the Filter icon in the Sort & Filter group. This will apply the filter to the first row in your dataset.
click the filter icon in the ribbon

You can also use the keyboard shortcut Control + Shift + L to apply the filters.

  1. Click on the Filter icon in the column that has the cells with color. In this case, since the entire row has been covered, you can click on the filter icon for any column.
click the filter drop down icon in the column header
  1. Hover the cursor over the ‘Filter by Color’ option. This will further show a sub-menu of the ‘Filter by Cell Color’ options.
hover the cursor over the filter by color option
  1. Select the color based on which you want to filter this data set. In this example, since we only have one color, only one color is shown in the options. In case you have multiple colors, all would be shown here.
select the colour based on which you want to filter the data

The above steps would instantly filter your data set, and you would only see the records where the specified color is filled in the cell.

data filtered by color in Excel

One limitation of this method is that you can only filter based on one color. Unlike the text or number filter, the filter-by-color functionality does not allow you to filter based on multiple colors

Filter by Font Color

You can also follow the same steps to filter your data set based on the font color instead of the cell color.

Below I have a data set where I have some records that are in red font color, and I want to filter all these records

data set where we want to filter by font color

Here are the steps to do this:

  1. Select the data (or any cell in the dataset)
  2. Click the Data tab
  3. Click on the Filter icon in the Sort & Filter group.
click the filter icon in the ribbon
  1. Click on the Filter icon in the column with the cells with color.
filter drop down icon in the column header
  1. Hover the cursor over the ‘Filter by Color’ option. This will further show a sub-menu of the ‘Filter by Font color’ options.
  2. Select the font color based on which you want to filter this data set. In this example, we only have one font color. In case your dataset has more, all the colors would show up.
select the font color based on which you want to filter the data

The above steps will filter the data, and we’ll keep only those records visible that have the selected font color.

data set filter based on the font color

Removing the Filter

If you want to remove the color filter, follow the below steps:

  1. Click on the filter icon in the column header where you applied the filter. You can also visually see which column has the filter applied as the icon changes from a simple dropdown icon to a filter icon.
  2. Select the ‘Clear Filter from…’ option.
Clear filter form column Excel

Filter By Color Using Right-click Menu

Another fast way to filter by color is by using the filter option that appears when you right-click on the cell that has the color.

Let me show you how it works.

Filter by Cell Color

Below I have the same data set where I have some colored cells that I want to filter.

Filter by color data set

Here are the steps to filter my color using the right-click menu:

  1. Right-click on any of the cells that have the color based on which you want to filter the data
Right click on any of the colored cell
  1. Hover the cursor over the Filter option.
  2. In the additional options that appear, click on the ‘Filter by Selected Cell’s Color’ option.
select filter by selected cells color option

That’s it! Your data set would instantly be filtered based on the cell in which you right-clicked.

This method has the same limitation, where you cannot filter based on multiple colors. You can only filter based on one color.

Filter by Font Color

Similarly, you can also quickly filter based on the font color by simply right-clicking on the cell and then choosing the right filter option.

Below I have a data set where I have some cells that are in red font color, and I want to filter these records.

data set where we want to filter by font color

Here are the steps to do this:

  1. Right-click on any of the cells that have the font color based on which you want to filter
  2. Hover the cursor over the Filter option.
  3. In the additional options that appear, click on the ‘Filter by Selected Cell’s Font Color’ option.
select filter by selected cell font color option

Removing the Filter

Below are the steps to remove the cell color or font color filter:

  1. Right-click on any of the cells in the column that has been filtered
  2. Hover the cursor over the Filter option
  3. Select the ‘Clear Filter from…’ option.
Clear filter option in right click menu

Filter By Color Using VBA

While the above two methods are fast and easy, a big limitation is that you can only filter your data set based on one single color.

But what if you have multiple colors in your data set and you want to filter your data to get records that are highlighted in two or more colors?

Let me show you a very simple VBA code and a smart technique to do this.

Below, I have a data set where I have cells highlighted in two colors (green and orange), and I want to filter all the records that have green and orange colors.

data set with multiple cell fill color

Since I cannot do this using the regular Filter by Color functionality in Excel, I will add a helper column and then extract the color index value of each cell color in that helper column.

Once I have these values in the helper column, I can easily filter based on multiple colors using multiple color index values.

The first step for this would be to create a custom function in VBA and then use that function in the worksheet to get the color index for each cell.

Below are the steps to create the custom function in Excel:

  1. Click the Developer tab and then click on the Visual Basic icon. This will open the VB Editor. You can also use the shortcut ALT + F11 (hold the ALT key and then press the F11 key)
click on the visual basic option in the ribbon
  1. Click on the Insert option in the menu
  2. Click on the Module option. This will insert a new Module for our workbook
insert a new module
  1. Copy and paste the below code to the module code window.
'Code developed by Sumit Bansal from https://trumpexcel.com
Function GetCellColor(cell As Range) As Integer
GetCellColor = cell.Interior.ColorIndex
End Function

'Code developed by Sumit Bansal from https://trumpexcel.com
Function GetCellFontColor(cell As Range) As Integer
GetCellFontColor = cell.Font.ColorIndex
End Function
copy paste the code in the module code window
  1. Close the VB Editor

With the above steps, we have created two functions using VBA that can now be used in the worksheet as regular functions.

The GetCellColor function will take the cell reference as the input and give us the numerical value that represents the color index of that cell.

And the GetCellFontColor function takes the cell reference as input and gives us the cell font color index value.

Now let’s see how to use these functions in the worksheet to filter our data by color.

  1. In cell C1, enter the text ‘ColorIndex”. We are doing this as we need a header for our helper column. You can write any text you want.
enter helper column header
  1. Enter the below text in cell C2, and then copy it for all the cells in the column.
=GetCellColor(B2)
Use the GETCELLCOLOR function

The numerical value that you see in the helper column represents the color index value of each cell on the left. So 15 represents the green color in our dataset, 40 represents orange, and -4142 represents no color.

Now that we have all the data, we will see how to filter this data set based on multiple colors.

  1. Select the entire data set.
  2. Click the Data tab
  3. Click on the Filter icon. This will apply filters to the entire first row, including the header of the helper column.
click the filter icon in the ribbon
  1. Click the filter icon in the helper column.
click on the filter drop down icon in the helper column
  1. Uncheck the options you don’t want to filter for and keep the numbers for the colors for which you want to filter the data. In our example, we will keep 15 and 40 checked (and uncheck all other options).
unselect everything and only keep selected the color index that you want to filter
  1. Click on OK

The above steps would filter our data set based on the selected colors.

data set filter based on multiple colors

Once done, you can hide or remove the helper column if you don’t want it.

Note: In case you want to filter the dataset based on the cell font color instead, use the GetCellFontColor function in step 8.

So these are the methods you can use to filter by color in Excel. If you want to filter just by one cell color or font color, then you can use the right-click technique or apply the filter and then use the options in the filter drop-down (as shown in Method 2 and Method 1, respectively).

And if you need to filter based on multiple colors, you will have to create a User-defined function using VBA and then use that function in the worksheet to fetch the color index, which can then be used to apply the filter.

Other Excel articles you may also like:

  • Excel Filter Function – Explained with Examples + Video
  • Excel VBA Autofilter: A Complete Guide with Examples
  • How to Filter Cells that have Duplicate Text Strings (Words) in it
  • How to Filter Cells with Bold Font Formatting in Excel (An Easy Guide)
  • How to Sum by Color in Excel (Formula & VBA)
  • How to Sort By Color in Excel
  1. Image titled Filter by Color in Excel Step 1

    1

    Open your project in Excel. You can either open your spreadsheet within Excel by navigating to File > Open or by right-clicking the file in your file manager and selecting Open with > Excel.

  2. Image titled Filter by Color in Excel Step 2

    2

    Select the column you want to filter. To select the entire column, click the header cell (which is usually a letter).

    Advertisement

  3. Image titled Filter by Color in Excel Step 3

    3

    Click Data. You’ll see this tab in the editing ribbon above the spreadsheet editing space.

  4. Image titled Filter by Color in Excel Step 4

    4

    Click Filter. This is next to an icon of a filter.

  5. Image titled Filter by Color in Excel Step 5

    5

    Click

    Android 7 Dropdown

    next to the column that contains the data you want to filter. A window will drop-down.

  6. Image titled Filter by Color in Excel Step 6

    6

    Click the drop-down menu next to «By color» under the «Filter» header. You’ll want to use the color field under «Filter» since the other field is only for setting how to sort the appearance on the spreadsheet.

    • You might see «Filter by color» instead.
  7. Image titled Filter by Color in Excel Step 7

    7

    Select either Cell color or Font color. Another menu will open to the right with color choices.

    • After you make a selection, only the color you chose will appear on the spreadsheet.[1]
  8. Advertisement

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Thanks for submitting a tip for review!

References

About This Article

Article SummaryX

1. Open your project in Excel..

2. Select the data you want to filter by.

3. Click Data.

4. Click Filter.

5. Click the downwards-pointing arrow next to the column that contains data you want to filter.

6. Click the drop-down menu next to «By color» under the «Filter» header.

7. Select either Cell color or Font color.

Did this summary help you?

Thanks to all authors for creating a page that has been read 31,720 times.

Is this article up to date?

Do you have colored cells that need to be filtered?

You are probably already filtering based on the cell values but that same filtering can be based on the cell color as well.

For example, you may have a table of data and decide to add a fill color format. You could color each cell based on the cell content and then filter by the color!

This post will show you all the ways to filter by color in Excel.

Filter by Color from Filter Toggles

The most common way to filter data in Excel is through the filter toggles. Once you enable the data filter you can filter by color with its built-in menu.

Follow these steps to filter by color.

  1. Select your table header cells.

  1. Under the Data tab toggle the Filter menu button. The filter toggles will appear on your headers.

💡 Tip: You can quickly apply the filter toggles to your data by using the Ctrl + Shift + L keyboard shortcut. This is an easy way to toggle on or off the filters for any data in your Excel workbook.

  1. Select the filter toggle for your column of colored cells.

  1. Hover over the Filter by Color option and choose the color to filter based on from the submenu.

Immediately your table has been reduced to only showing rows containing green cells!

Filter by Color from the Right Click Menu

You can quickly filter rows through the right-click menu without having to manually enable the filter toggles.

To filter a single color this way:

  1. Right-click on a cell whose color you’d like to filter.

  1. Drill down to the Filter options.

  1. Choose Filter by Selected Cell’s Color.

Notice how the filter toggles are automatically enabled and your table has been filtered to show only rows containing green cells!

Filter by Color with VBA

VBA is a programming code you can leverage to automate many Excel tasks including filtering.

You can write a VBA macro that will filter by the currently selected cell’s color:

  1. Open the Visual Basic Editor by pressing Alt + F11 or going to the Developer tab and selecting Visual Basic. You may need to enable the Developer tab if it is hidden from the ribbon.

  1. Select the Insert menu and choose the Module option.

Sub FilterByColor()

Dim selCell As Range
Dim color, field

Set selCell = Selection

If Intersect(selCell, ActiveSheet.UsedRange) Is Nothing Then
    'No table selected
    Exit Sub
End If

If ActiveSheet.autofilter Is Nothing Then
    'Turn on filter toggles
    selCell.autofilter
End If

field = selCell.Column - ActiveSheet.autofilter.Range.Column + 1
color = selCell.Interior.color

'Filter by color
selCell.autofilter field:=field _
    , Criteria1:=color _
    , Operator:=xlFilterCellColor

End Sub
  1. Double-click the new module to open it and paste the above VBA code into that module.

The code first ensures you’ve selected within the table. selCell is the selected cell whose color you want to filter. field is the table’s field number containing the colored cells.

This example has a field number of 2 because the field that needs to be filtered is the second table column. color is the color of the selected cell.

You can then run the code.

  1. Go back to your sheet and select a cell whose color you want to filter.

  1. Under the View menu select Macros.

  1. Select your FilterByColor macro.
  2. Click the Run button.

Your table now appears filtered by the color of the cell you selected!

Filter by Color with Office Scripts

You can use Office Scripts in Excel if you have an online version of Excel under a Microsoft 365 business plan.

Microsoft also introduced Office Scripts to the recent beta version of Excel for the Desktop.

You can use Office Scripts to automate tasks like color filtering as follows.

Open your workbook that contains your table data.

  1. Go to the Automate tab.
  2. Select New Script.

Ensure you have a version of Excel that supports Office Scripts if you don’t see the Automate tab.

function main(workbook: ExcelScript.Workbook) {
	//Worksheet
	let selectedSheet = workbook.getActiveWorksheet();
	//Selected cell
	let cell = workbook.getActiveCell();

	if(selectedSheet.getUsedRange().getIntersection(cell)==null){
		return;
	}

	//Turn on filter toggles
	let af = selectedSheet.getAutoFilter();
	af.apply(cell);

	//Color of selected cell
	let color = cell.getFormat().getFill().getColor();

	//Column index within table
	let col = cell.getColumnIndex() - af.getRange().getColumnIndex();

	//Filter by color
	af.apply(af.getRange(), col, {filterOn: ExcelScript.FilterOn.cellColor, color: color});

}
  1. Paste over the entire contents of the Code Editor pane with the above script.

The script gets the active cell and retrieves its color to determine what color to filter by.

The filter toggle af is turned on and the filtered column index is stored in the col variable. The table column index always starts at 0 so the index for the column that needs filtering is 1.

The last line uses all the info to apply the color filter.

You can then see the results of your script.

  1. Select any colored cell on your sheet.

  1. Click the Run button found in the Code Editor pane.

Notice that the color you selected has now been filtered in your table!

Conclusions

This post showed you several different ways to filter by color in an Excel table.

Filtering your color with the toggle filters is a good method to use when you already have filtering set up the way you like.

Going through the right-click menu is a quick alternative but be aware that Excel guesses at your table’s cell range when doing this.

You get complete control over your color filtering if your use VBA or Office Scripts and you can reliably repeat the filtering on different sheets. These are good tools if you have the supported Excel version and the programming knowledge to do it.

Have you ever needed to filter your data based on cell color? Did you know you could do this? Let me know in the comments below!

About the Author

Barry O'Brien

Barry is a software development veteran with a degree in Computer Science and Statistics from Memorial University of Newfoundland. He specializes in Microsoft Office and Google Workspace products developing solutions for businesses all over the world.

Home / Advanced Excel / How to Filter by Color in Excel

In Excel, when you apply a filter to a column, you have the option to filter values based on the font color and cell background color. This option is already available in the filter, you don’t have to activate anything for this once you apply a filter.

filter-by-color

Steps to Filter a Column by Color in Excel

  1. First, apply the filter to the column.
  2. After that, click on the filter drop-down.
  3. Next, go to the “Filter by Color” option.
  4. In the end, choose the color which you want to choose to apply the filter.

As I said, you have two ways to use color to filter values:

  • By Cell Color
  • By Font Color

In the following example, we have used the red font color to apply the filter. And it has filter values that have red as a font color.

used-red-font-for-filter

In the same way, you can filter based on cell color. And in the below example, we have used the yellow cell color to filter values.

filter-based-on-cell-color

When you open the “Filter by Color”, you have the option to filter cells where you don’t have any cell color or font color.

filter-the-cells-with-no-color

Let’s say you want to filter all the cells based on the cell color of the selected cell.

filter-by-right-click-menu
  1. Select the cell.
  2. Right-click on it.
  3. Go to the Filter Option.
  4. Click on “Filter by Selected Cell’s Color”.
filter-by-selected-color

In the same way, you can filter the cells based on the font color of the cell.

filter-based-on-font-color

Use the “Filter by Selected Cell’s Font Color”.

filter-by-selected-font-color

Notes

  • You can’t apply a filter based on cell color and font color at the same time on a single color. One type of filter can be used at a time.
  • You can apply a filter on multiple columns based on font and cell color. For example, you can filter one column based on the red font color and filter the second column based on the yellow cell color.

Понравилась статья? Поделить с друзьями:
  • Excel fill cells color if
  • Excel files что это
  • Excel files with data
  • Excel file cannot be opened because
  • Excel file attributes a