View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Any way to capture an Autofilter event?

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


"mrwaller" wrote in message
...
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.