View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default using auto filter, how to tell what columns are filtered?

The code doesn't go in the ThisWorkbook module. It belongs in a General module.

Some more links:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm



Robert Mark Bram wrote:

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
:)


--

Dave Peterson