Hi all, what I am trying to do is use a vba filter, and have it show what I filtered on in the above cell (a1). I found this code but can't seem to make it work. I put it in a modual, and on the filter sheet (sheet1),cell a1,I put =FilterCriteria A3
but it dont seem to work. Thanks for any help Dan
Here is the Modual Code:
Function FilterCriteria(Rng As Range) As String
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 x1And
Filter = Filter & " AND " & .Criteria2
Case x1Or
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish
FilterCriteria = Filter
End Function
but it dont seem to work. Thanks for any help Dan
Here is the Modual Code:
Function FilterCriteria(Rng As Range) As String
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 x1And
Filter = Filter & " AND " & .Criteria2
Case x1Or
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish
FilterCriteria = Filter
End Function