Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Auto Filter

Status
Not open for further replies.

Dickx

Technical User
Aug 24, 2001
33
US
Using Excel's auto filter function, how can I change the color of the drop down filter or the column that I am filtering.
 
Copy the following code to the worksheet Selection Change event.

Code:
    Dim rng As Range
    
    
    If ActiveSheet.AutoFilterMode = True Then
        For Each rng In Range("A1", Range("A1").End(xlToRight))
            With ActiveSheet.AutoFilter.Filters(rng.Column)
                If .On Then
                    rng.EntireColumn.Interior.ColorIndex = 6
                Else
                    rng.EntireColumn.Interior.ColorIndex = xlNone
                End If
            End With
        Next rng
    End If

There is a restriction here - the columns will only change colour if you click on a different cell. Selecting a different item in the drop-down filter will not trigger the code unless you also click somewhere else on the sheet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top