excel - Loop through filter criteria -
i've been trying figure out no progress...
i have filter (column d) , i'm trying create loop each criteria (i got @ least 1000 criterias) on filter. ex: each criteria on filter (column d), i'll run range copy...
that code isnt working @ all:
sub whatfilters() dim ifilt integer ifilt = 4 dim ifiltcrit integer dim numfilters integer dim crit1 variant activesheet.range("$a$1:$aa$4635").autofilter field:=16, criteria1:= _ "waiting" numfilters = activesheet.autofilter.filters.count debug.print "sheet(" & activesheet.name & ") has " & numfilters & " filters." if activesheet.autofilter.filters.item(ifilt).on crit1 = activesheet.autofilter.filters.item(ifilt).criteria1 ifiltcrit = 1 ubound(crit1) debug.print "crit1(" & ifiltcrit & ") '" & crit1(ifiltcrit) 'copy next ifiltcrit end if end sub
my mistake seems identifying filter column...
this worked me
sub whatfilters() dim ifilt integer dim i, j integer dim numfilters integer dim crit1 variant if not activesheet.autofiltermode debug.print "please enable autofilter active worksheet" exit sub end if numfilters = activesheet.autofilter.filters.count debug.print "sheet(" & activesheet.name & ") has " & numfilters & " filters." = 1 numfilters if activesheet.autofilter.filters.item(i).on crit1 = activesheet.autofilter.filters.item(i).criteria1 if isarray(crit1) '--- multiple criteria selected in column j = 1 ubound(crit1) debug.print "crit1(" & & ") '" & crit1(j) & "'" next j else '--- single criteria selected in column debug.print "crit1(" & & ") '" & crit1 & "'" end if end if next end sub
Comments
Post a Comment