PDA

View Full Version : VBACode to show autofilter criteria just show result as <>, even though filter is set



S Svarholt
02-10-2018, 08:32 AM
Hi!

I have used the below code for a while, but a few days ago it suddenly stopped working. Can anybody please help me with a solution for this? It's not working on any computer it's tested on.



Function DispCriteria(Rng As Range) As String
Dim Filter As String

Filter = ""
On Error GoTo Done
With Rng.Parent.AutoFilter
If Intersect(Rng, .Range) Is Nothing Then GoTo Done
With .Filters(Rng.Column - .Range.Column + 1)
If Not .On Then GoTo Done
Filter = .Criteria1
Select Case .Operator
Case xlAnd
Filter = Filter & " AND " & .Criteria2
Case xlOr
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Done:
DispCriteria = Filter
End Function



Where I want to use it in the Excel-file, I use "=DispCriteria(A31)" to get the filter criteria. But a few days ago it just started to show me the result <> in that cell. Anyone that can help a lost noob? Hehe

Best regards

p45cal
02-11-2018, 05:52 AM
It will show that if you're filtering to exclude blanks (and only blanks).