PC Review


Reply
Thread Tools Rate Thread

How can I detect change to Autofilter selection

 
 
MikeZz
Guest
Posts: n/a
 
      22nd Jul 2009
Is there a way to detect a change in a sheet's Autofilter Selection?

ie... when I change Autofilter for column 5, I need to get what the new
values are for Title, Criteria1 etc....

Thanks!
 
Reply With Quote
 
 
 
 
Héctor Miguel
Guest
Posts: n/a
 
      23rd Jul 2009
hi, Mike !

> Is there a way to detect a change in a sheet's Autofilter Selection?
> ie... when I change Autofilter for column 5, I need to get what the new values are for Title, Criteria1 etc...


following is an "ancient" procedure I used in the filtering worksheet code module (_calculate event)
to put a formula in cell [E2] and linked to a textbox (shape drawing)

hth,
hector.

Private Sub Worksheet_Calculate()
Dim myFormula As String, nFilter As Integer, Filtered As Integer, Filtering As String
If Not Me.AutoFilterMode Then Exit Sub
Application.ScreenUpdating = False
myFormula = "=""Filtering by:"""
With Range(Me.AutoFilter.Range.Address)
For nFilter = 1 To .Columns.Count
With .Cells(1, nFilter)
If Me.AutoFilter.Filters(nFilter).On Then
Filtered = Filtered + 1
Filtering = CStr(.Value)
With Me.AutoFilter.Filters(nFilter)
myFormula = myFormula & "&" & _
"Char(10)" & "&""" & Filtered & ".- " & Filtering & ". Criteria " & .Criteria1
If .Operator = xlAnd Then myFormula = myFormula & " AND 2nd criteria " & .Criteria2
If .Operator = xlOr Then myFormula = myFormula & " OR 2nd criteria " & .Criteria2
myFormula = myFormula & """"
End With
End If
End With
Next
End With
If Filtered = 0 Then myFormula = _
"=""Actually""" & "&" & "Char(10)" & "&" & """There is NO active filters !!!"""
Me.Range("e2").Formula = myFormula
End Sub


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect Autofilter Change Event Alan Z. Scharf Microsoft Excel Programming 2 13th Mar 2009 10:01 PM
AutoFilter Selection to Change Page Header Darrell Lankford Microsoft Excel Programming 0 29th Apr 2008 06:38 PM
Detect combo box selection change ? =?Utf-8?B?bXNjZXJ0aWZpZWQ=?= Microsoft Access Form Coding 3 9th May 2006 09:07 PM
Datasheet Subform - Detect Selection Change Andibevan Microsoft Access Form Coding 0 2nd May 2006 07:46 PM
Autofilter.Selection - After Change Event??? Paul M. Microsoft Excel Programming 0 15th Aug 2003 05:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:54 PM.