Alternate to Sheet_Calc when Filter applied.
Changing a filter does not directly trigger any events, though the calculate
might fire. One way to force it is with something like this -
=Subtotals(3, ref).
The value will change when any values in the range are un/hidden, and in
turn the Calculate event. Of course the Calculate event may fire
irrespective of any change to the filter. So start with say
Dim b As Boolean
b = ActiveSheet Is Me ' we're on this sheet
If b Then b = Me.FilterMode ' filter exists
If b Then
' other checks etc, eg compare old filter properties with new
' or maybe check specialcells visiblecells for hidden rows
Regards,
Peter T
"Trevor Williams" wrote in
message ...
Hi All
I'm using the Worksheet_Calculate event to show/hide 2 images on the
active
sheet when a filter is applied. The issue is that the event fires whether
I'm on the sheet or not.
My question then is: Is there an alternate way I can show/hide the images
without using the Worksheet_Calculate event when a filter is applied?
Code below
Thanks in advance
Trevor Willams
'Worksheet module
Private Sub Worksheet_Calculate()
Call ShowClearFilterButton
End Sub
'Code Module
Sub ShowClearFilterButton()
With ActiveSheet
On Error Resume Next
If .AutoFilterMode = True Then
If .FilterMode = True Then
.Shapes("picFilter").Visible = msoTrue
.Shapes("btnFilter").Visible = msoTrue
Else
.Shapes("picFilter").Visible = msoFalse
.Shapes("btnFilter").Visible = msoFalse
End If
End If
End With
End Sub
|