arrays - Looping through filtered column cells: Excel VBA -


i have table of data headers going across top , left side. filtering each column, 1 @ time(starting @ column 2). want assign value(the header left) array each of rows still present after filtering. code, however, not pull filtered range, unfiltered range. ex: filtered range rows 1,4,8,9 , excel pulls 1,2,3,4. ideas how can modify code?

constant = 0: = 1: o = 1 application.visible = true set ws_prods_with = sheets.add  z = 3 lstcol1  ra_counter = 0: cp_counter = 0: counter = 0 redim prodwith(1 1) prodwith(1) = "" 'clearing out array ws_sel     if (.autofiltermode , .filtermode) or .filtermode     .showalldata 'turning off previous filter     end if     on error resume next     .range(.cells(1, 1), .cells(counter, lstcol1)).autofilter field:=z, criteria1:="yes"     set rngfilter_yes = intersect(.usedrange, .usedrange.offset(1), _     .columns(2)).specialcells(xlcelltypevisible)      lstrow_yes = .cells(.rows.count, "a").end(xlup).row - 1 'last row in filtered column      if lstrow_yes > 0         set rngfilter_yes2 = rngfilter_yes     elseif lstrow_yes = 0 'no yes's in column         redim preserve prodwith(1 2)         prodwith(1) = ws_sel.cells(v + 1, 1).value          prodwith(2) = "no products"         ws_prods_with             .range(.cells(z - 2, 1), .cells(z - 2, 2)) = prodwith          end         goto nocells 'skip rest of code     end if  end      each cel in rngfilter_yes2 'check filtered column yes's! add appropriate counter         select case cel             case = "~"             case = "ra": ra_counter = ra_counter + 1             case = "comp": cp_counter = cp_counter + 1         end select     next cel  total = cp_counter + ra_counter    v = 1 total                          counter = counter + 1         redim preserve prodwith(1 counter)         prodwith(v) = ws_sel.cells(v + 1, 1).value   next v 


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -