View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Robert Mark Bram Robert Mark Bram is offline
external usenet poster
 
Posts: 5
Default using auto filter, how to tell what columns are filtered?

Hi Dave,

Thank you very much for your response!

I saved this from a Tom Ogilvy post:
====================================

http://j-walk.com/ss/excel/usertips/tip044.htm
orhttp://spreadsheetpage.com/index.php/tip/displaying_autofilter_criteria/


Following http://j-walk.com/ss/excel/usertips/tip044.htm, here is what
I did:

1) Added a new row at top of my spreadsheet, so the filters are at row
2.
2) Pressed Alt+11 to get to Microsoft Visual Basic.
3) Double clicked on ThisWorkbook.
4) Pasted in
Function FilterCriteria(Rng As Range) As String
'By Stephen Bullen
Dim Filter As String
Filter = ""
On Error GoTo Finish
With Rng.Parent.AutoFilter
If Intersect(Rng, .Range) Is Nothing Then GoTo Finish
With .Filters(Rng.Column - .Range.Column + 1)
If Not .On Then GoTo Finish
Filter = .Criteria1
Select Case .Operator
Case xlAnd
Filter = Filter & " AND " & .Criteria2
Case xlOr
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish:
FilterCriteria = Filter
End Function
5) Saved and closed VB.
6) In the cell above G2 (which has a filter), inserted:
=FilterCriteria(G2)
7) I get #NAME? error in G1.

Any ideas?

Thanks again. :)

Rob
:)