arrays - VBA to AutoFilter Dataset Based on Slicer Selections -


i have series of slicers controlling number of pivot tables in turn generate pie charts. slicer items selected autofilter underlying dataset summarise information used generate pies. far have managed generate following code admit have gleaned post here: autofilter criteria using array (error) - large string? code below autofilter dataset using last item selected in slicer , not other selections, i.e. if items of slicer selected autofilter filters using last item , not full series. appears array element not working expected. assistance gratefully accepted. thank you.

sub filterdata() dim sarr() string dim scache slicercache dim wb workbook set wb = thisworkbook set scache = wb.slicercaches("slicer_unit")    each sitem in activeworkbook.slicercaches(scache.name).sliceritems         if sitem.selected = true             redim preserve sarr(0 scount)             sarr(scount) = sitem.name             scount = scount + 1         end if     next sitem  sheets("sheet1").activate activesheet.range("$a$1:$z$50000").autofilter field:=1, criteria1:=sarr() redim sarr(0 0) end sub 

you need specify type of criteria you're providing using operator parameter. change line

activesheet.range("$a$1:$z$50000").autofilter _   field:=1, _   criteria1:=sarr() 

to

activesheet.range("$a$1:$z$50000").autofilter _   field:=1, _   criteria1:=sarr(), _   operator:=xlfiltervalues 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -