Using Autofilter with User Input

  • Thread starter Thread starter kylec
  • Start date Start date
K

kylec

I have a 10,000 row parts catalog worksheet, with columns for parts #,
part location, and description. I want to filter the description
column based on the what the user enters in a user form. I am having
some trouble doing this though. Here is some code I tried (from
recording a macro), where "input1" and "input2" are what I have named
the text box values in the user form that the user enters the search
criteria.

Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=*input1*",
Operator:=xlAnd, _
Criteria2:="=*input2*"

What is actually happening when I use this code is that the column is
being filtered by the actual words input1 and input2, as opposed to
being filtered by the userform textbox values that I assigned to the
names input1 and input2.

Any help on how to fix this would be greatly appreciated. Also, if
anyone has suggestions on maybe a better method to search or filter a
catalog, using a very easy and simply user interface, it would be
awesome. Thanks,

Kyle
 
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=*" & input1 & "*",
Operator:=xlAnd, _
Criteria2:="=*" & input2 & "*"

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
Back
Top