» Set up yellow background color for header in an AutoFilter table using VBA in Microsoft Excel
CATEGORY - General Topics in VBA
VERSION - All Microsoft Excel Versions
When filtering a column, the header row is to be highlighted with a yellow background color
Answer:
Insert the following code in the appropriate modules.
Place the code below into the standard module.
Private Sub Worksheet_Calculate()
Dim flt As Filter
Dim intCol As Integer
For Each flt In ActiveSheet.AutoFilter.Filters
intCol = intCol + 1
If flt.On Then
Cells(1, intCol).Interior.ColorIndex = 6
Else
Cells(1, intCol).Interior.ColorIndex = xlColorIndexNone
End If
Next flt
End Sub
Book Store:
Recommended Books:
- Special Edition Using Microsoft Access 2002
- Rich Dad's Guide to Investing: What the Rich Invest in, That the Poor and the Middle Class Do Not!
- Microsoft Excel 2002 Formulas (With CD-ROM)
- East of Eden (Oprah's Book Club)
- Microsoft Office Xp: Advanced Concepts and Techniques: Word 2002, Excel 2002, Access 2002, Powerpoint 2002
- Special Edition Using Microsoft Excel 2002
No comments have been submitted.

