
Tips.Net > ExcelTips Home > Filtering > AutoFilter > Changing AutoFilter Drop-Down Arrow Colors
Summary: The drop-down arrow used at the top of columns by AutoFilter can be difficult to see. Here’s a way you can reduce the confusion about which columns are filtered in your worksheet. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
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.
Tip #2371 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Step Up and Take Control! Subscribers to ExcelTips know just how valuable a resource it is. ExcelTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on ExcelTips archives and e-books.
Check out ExcelTips Premium today!
No, not that type of date. If you need to do any types of work with calendar dates, Excel has the tools you need. Learn how to use those tools the easy way. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site