excel - Using string array as criteria in VBA autofilter -


i've searched other posts , found similar issues nothing me specifically. i'm trying take array of strings , use filter criteria. it's tricky because array created function , has variable number of elements , contents. need autofilter take , check column e each 1 of elements.

i've tried 2 ways

1)

with sheet17   .range("e1").autofilter field:=5, criteria1:=application.transpose(arr)  end 

result: applies filter column e fails select of options

2)

for = 0 counter - 1    sheet17      .range("e1").autofilter field:=5, criteria1:=application.transpose(arr(i)) end  next 

note: counter integer representing number of elements in array result: 1 correctly loops through array selects last option on filter - presumably because every time loops through starts on , unchecks every other option end recent option remains checked.

you not need transpose single element array , cannot put criteria 5th field if referencing column e.

dim long, arr variant arr = array(1, 3)  sheet17     'to filter each value in array 1 @ time     = 0 ubound(arr)         .columns("e").autofilter field:=1, criteria1:=arr(i)     next      'my values numbers - autofilter likes strings in array     = lbound(arr) ubound(arr)         arr(i) = cstr(arr(i))     next      'to filter values in array @ once specify xlfiltervalues     .columns("e").autofilter field:=1, criteria1:=arr, _                              operator:=xlfiltervalues end 

specify operator:=xlfiltervalues when passing array , range.autofilter method likes strings values in array.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -