ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trapping the AutoFilter Event (https://www.excelbanter.com/excel-programming/438396-trapping-autofilter-event.html)

PosseJohn

Trapping the AutoFilter Event
 
I have a worksheet that has the AutoFilter enabled.

Is there a method to trap when the user selects to perform the AutoFilter?

I want to carry out a few steps when they do.

marcus[_3_]

Trapping the AutoFilter Event
 
Hi John

Try this from should get you what you want. Need to change the sheet
name and insert your actions.

Take care

Marcus

Sub autofil()

With Worksheets("Sheet1")
If .AutoFilterMode Then
'Your code here
End If
End With

End Sub

PosseJohn

Trapping the AutoFilter Event
 
I don't see how that would work...if the user performs a AutoFilter action,
what would trigger the Sub AutoFil procedure?


"marcus" wrote:

Hi John

Try this from should get you what you want. Need to change the sheet
name and insert your actions.

Take care

Marcus

Sub autofil()

With Worksheets("Sheet1")
If .AutoFilterMode Then
'Your code here
End If
End With

End Sub
.


marcus[_3_]

Trapping the AutoFilter Event
 
Sorry misread your post.

This from the msdn website

"One of the limiting aspects of using the AutoFilter feature in a
business solution is that it has no directly associated event in the
Excel object model. In other words, when a filter is applied or
changed, by a user or programmatically, there is no explicit event for
the activity."

The article goes on to explain a way to capture the autofilter event
with the use of smart tags. Will let you get your head around it. It
is worth reading.

http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

Take care

Marcus

Gary''s Student

Trapping the AutoFilter Event
 
You can use the Calculate Event to trap AutoFilter changes. For example:

=SUBTOTAL(2,A:A)

will give the count of visible cells in column A. Excel re-calculates this
whenever the AutoFilter is adjusted and the event gets triggered.
--
Gary''s Student - gsnu200909


"PosseJohn" wrote:

I have a worksheet that has the AutoFilter enabled.

Is there a method to trap when the user selects to perform the AutoFilter?

I want to carry out a few steps when they do.



All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com