PDA

View Full Version : Auto filter criteria



peterwmartin
01-05-2016, 10:53 PM
Hi all,
Stuck with a problem, it may be simple but I'm just not getting it.
Userform1 has a textbox in which I put a value, want the autofilter to filter between + or - 10 of that number
I have tried textbox1.value & "<10" and a couple of different variations, syntax has me stuffed.

Also textbox2.value to filter one column and textbox3.value to filter another and give me either results, I can get them to work individually however not together.
Any help appreciated spent hours searching for the answer found heaps of solutions for filtering different values on one column,
no xlOr for 2 columns.
Cheers

Bob Phillips
01-06-2016, 01:38 AM
rng.AutoFilter Field:=1, _
Criteria1:=">=" & TextBox1.Value - 10, _
Operator:=xlAnd, _
Criteria2:="<=" & TextBox1.Value + 10

peterwmartin
01-06-2016, 02:06 AM
thanks xld works like a charm, I think i might have the xlOr bit.....

Bob Phillips
01-06-2016, 04:24 AM
That would have to be two filters, xlOr refers to a filter being A or B, not column A Or column B.