Changing AutoFilter Drop-Down Arrow Colors

by Allen Wyatt
(last updated March 1, 2014)

4

Gus asked if there was a way to change the color of the drop-down arrows that appear at the top of each column when AutoFilter is turned on. When a filter is not applied to a column, the drop-down arrow is black; when a filter is applied, the drop-down arrow is navy blue. Gus wanted to change the colors because there isn't enough contrast between black and navy blue on his monitor.

Unfortunately, it appears that the color of the drop-down arrows is hard-coded into Excel and cannot be changed. You can try a workaround, if you desire, that would instead color the first cell in each of the filtered columns. Add the following macro to a regular module in the workbook:

Sub ColorDisplayFilter()
    Dim flt As Filter
    Dim iCol As Integer
    Dim lRow As Long

    iCol = 0
    lRow = ActiveSheet.AutoFilter.Range.Row
    Application.EnableEvents = False
    For Each flt In ActiveSheet.AutoFilter.Filters
        iCol = iCol + 1
        If flt.On Then
            Cells(lRow, iCol).Interior.Color = vbYellow
        Else
            Cells(lRow, iCol).Interior.ColorIndex = xlColorIndexNone
        End If
    Next flt
    Application.EnableEvents = True
End Sub

The code steps through the filters for a worksheet and, if the filter is active for a column, colors the first cell yellow. If the filter is not active, then it gets rid of the yellow color.

To trigger the routine so that it runs automatically, there are two things you need to do. First of all, you need to add the following macro to the thisWorkbook object:

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
    If Sh.AutoFilterMode Then ColorDisplayFilter
End Sub

This triggers every time the worksheet is calculated. If the AutoFilterMode property is True, then the coloring macro is executed.

The second thing you need to do is add a SUBTOTAL formula to your worksheet. Assuming that column A is one of the columns in the filter, you could add the following to the worksheet:

=SUBTOTAL(9,A:A)

The SUBTOTAL function is recalculated every time a filter is changed, so this helps ensure that the coloring macro is executed. The formula can be hidden, if desired, but it must be on the worksheet that has the filter to ensure that the sheet triggers the event.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2371) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Backwards Date Parsing

Enter information into a worksheet, and you come to anticipate (and count on) how Excel will interpret that information and ...

Discover More

Checkboxes in a Merged Document

When creating a mail-merge document, you may want to include some special characters, such as check-marked boxes, in the ...

Discover More

Deleting Worksheet Code in a Macro

When creating an application in VBA for others to use, you might want a way for your VBA code to modify or delete other ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

MORE EXCELTIPS (MENU)

Toggling AutoFilter

Want a tool that will help you toggle AutoFilter on and off? Excel provides some tools you can use, but you need to be ...

Discover More

Using AutoFiltering

Excel's AutoFilter tool is a great way to make a long list of items much more manageable. This tip explains how to set up an ...

Discover More

Filtering to a Date Range in the Past

If you have a large number of data records, each with an associated date, you might want to filter that data so you see only ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is three minus 0?

2016-11-02 19:07:46

Peter

Hi
This is great. I find it works in other open workbooks as well as the one with the code. However, I get Run-time error ‘91’ - not all the time, but sometimes. How do I stop this?


2016-08-29 02:20:32

juzer

Hello Sir, can you please give me complete VBA code.. Thank You


2015-02-04 04:37:11

Stephen

Changing AutoFilter Drop-Down Arrow Colors. Allen Wyatt Tip (2371)

How to change Allen's Tip "to color the first cell in each of the filtered columns" to be activated as well if the sort filter function is used but no data filtered?
Appreciating Thank you
Stephen


2014-11-18 07:03:11

Gilberto

Hello Allen,
I understand that the macro scans all the filtered columns, which in my case is not "recommendable".
Would it be possible to have a "formula", say in the cell above the heading row, that "flags" if that heading cell has a filter "active"? That way I could easily add a "Conditional formatting" rule for the heading cell to change color when the filter is active.
Thanks in advance


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing
Share