Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Any way to capture an Autofilter event?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mrwaller - 20 Jan 2006 17:44 GMT
I want to execute some code whenever a filtering event has occurred
(selecting a value from the filter drop-down list). There are many events
that can occur on a worksheet (calculate, change, etc.) but none of them kick
off for a filter selection.
Bernie Deitrick - 20 Jan 2006 18:15 GMT
You can use the calculate event, but you need a formula that is dependent on the results of the
filter.  Name a cell FormCell, and put a formula like:

=SUBTOTAL(9,B1:B100)

into it.  Then name another cell ValueCell, and use code like this: you can replace the msgbox with
your code.

Private Sub Worksheet_Calculate()
If Range("FormCell").Value <> Range("ValueCell").Value Then
MsgBox "Filtered"
Application.EnableEvents = False
Range("ValueCell").Value = Range("FormCell").Value
Application.EnableEvents = True
End If
End Sub

HTH,
Bernie
MS Excel MVP

>I want to execute some code whenever a filtering event has occurred
> (selecting a value from the filter drop-down list). There are many events
> that can occur on a worksheet (calculate, change, etc.) but none of them kick
> off for a filter selection.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.