Thread: Filter
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Filter

You could get rid of the = sign in the UDF, but you may not want to. There are
other criteria that would make that first character important (like greater than
or equal to).

You may want to just ignore the first character in your =vlookup() statement
when you know that first character is an equal sign:

=vlookup(mid(filtercriteria(a4),2,255, .....

(Use a number larger than the string that can be returned--I used 255 in my
example.)

Wayne wrote:

Theres 1 more problem the result for A1 when I use the filter comes up with =
how do I get rid of that because I use a Vlookup formula for that cell and it
comes up NA.

"Elkar" wrote:

The code looks fine. Try changing the cell reference in your formula to
match the first row of your data rather than the header. In this case:

=FilterCriteria(A4)

HTH,
Elkar


"Wayne" wrote:

I`m back with one more question.I`m using the Function below I know its close
to what I want.The only thing is when I use it once it will not change the
value a second time is there a part of a code that I am missing.

A1 has formula =FilterCriteria(A3) with Auto filter in A3


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


--

Dave Peterson