Hi,
So I have a monthly report that I have automated to refresh with new data and perform other preparations. One tool I have will cause the header to change color if filtered. That way I don't forget the filter and allow it to mess up the rest of my work. I want to add the creation of this macro on a sheet object to my other preparations which I run as a batch. Here is the code that I use:
I was unsuccessful with recording this.
So I have a monthly report that I have automated to refresh with new data and perform other preparations. One tool I have will cause the header to change color if filtered. That way I don't forget the filter and allow it to mess up the rest of my work. I want to add the creation of this macro on a sheet object to my other preparations which I run as a batch. Here is the code that I use:
Code:
Option Explicit
Private Sub Worksheet_Calculate()
Dim c As Long
Dim bFiltered As Boolean
If ActiveSheet.AutoFilterMode Then
With ActiveSheet.AutoFilter.Filters
For c = 1 To .Count
If .Item(c).On Then
bFiltered = True
Exit For
End If
Next c
End With
ActiveSheet.AutoFilter.Range.Rows(1).Interior.Color = IIf(bFiltered, vbRed, RGB(217, 217, 217))
End If
End Sub
I was unsuccessful with recording this.