excel vba - use multiple cell values in autofilter criteria -
please me condition:
1) value present in cell p1,p2,p3,p4 user defined words "f","s" , na...
2) use user defined value criteria filtering data in range(y2:y2999)
the thing tried didn't work is:
sub c1() dim string dim b string dim c string dim d string = cells(1, 16).value b = cells(2, 16).value c = cells(3, 16).value d = cells(4, 16).value activesheet.range("$y$2:$y$2999").autofilter field:=1,_ criteria1:=array(a, b, c, d) end sub
i believe should add criteria2, criteria3, , criteria4.
i update line
activesheet.range("$y$2:$y$2999").autofilter field:=1,_ criteria1:=array(a, b, c, d) to be
activesheet.range("$y$2:$y$2999").autofilter field:=1, _ criteria1:="=" & a, _ operator:=xlor, _ criteria2:="=" & b, _ operator:=xlor, _ criteria3:="=" & c, _ operator:=xlor, _ criteria4:="=" & d or if going so:
activesheet.range("$y$2:$y$2999").autofilter field:=1,_ criteria1:=array(a, b, c, d) you should try adding xlfiltervalues operator this:
activesheet.range("$y$2:$y$2999").autofilter field:=1, _ criteria1:=array(a, b, c, d), _ operator:=xlfiltervalues
Comments
Post a Comment