vba - Excel Autofilter all but variable value -
so need filter values in row except one. got work, using part of code, filter on everything, "belgium", need there variable.
dim myvalue variant myvalue = inputbox("which country exclude? ") range("ab1").select activesheet.range("$b$1:$by$319696").autofilter field:=27, criteria1:="<>belgium"
for version of filter filter on particular country variable works fine:
dim myvalue variant myvalue = inputbox("which country filter on: ") range("ab1").select activesheet.range("$b$1:$by$319696").autofilter field:=27, criteria1:= _ myvalue activewindow.smallscroll down:=-30
so why not work:
activesheet.range("$b$1:$by$319696").autofilter field:=27, criteria1:= <>myvalue
also not know why structured this, generated record macro, _ criteria1:= _ myvalue
the "<>" isn't operator (which how tried use in "not working" example), rather needs part of string passing autofilter (which how did in working first example.)
activesheet.range("$b$1:$by$319696").autofilter field:=27, criteria1:= "<>" & myvalue
should work.
Comments
Post a Comment