excel vba - Looping rows in filtered table -


does have way of looping through rows in filtered tables?

i tend need use data filtered table populate document, in case statement of accounts worksheet. since rows non-continuous, previous methods of populating data using row number seem failing.

soawb separate workbook populated data tsoa table, of code works data filtered/hidden range still included.

j first empty row on soawb, @ end of loop when j=j+1 next empty row repeats population process

for k = 1 tsoa.databodyrange.columns(1).specialcells(xlcelltypevisible).count  soawb.worksheets(1).cells(j, 4) = tsoa.databodyrange(k, 6) 'debit amount  soawb.worksheets(1).cells(j, 5) = tsoa.databodyrange(k, 7) 'credit amt  soawb.worksheets(1).cells(j, 1) = tsoa.databodyrange(k, 3) 'date  soawb.worksheets(1).cells(j, 2) = right(tsoa.databodyrange(k, 3), 2) & "-" & tsoa.databodyrange(k, 2) 'reference number  select case tsoa.databodyrange(k, 1)  case "inv"      soawb.worksheets(1).cells(j, 3) = "invoice"  case "cr"      soawb.worksheets(1).cells(j, 3) = "credit"  case else      msgbox "invalid type"  end select  j = j + 1  next 

it perfect if k still relative row # position on table. have suggestions on how this, or alternative methods populate data (row row) workbook using filtered range?

hidden rows have height=0

you'll have loop on used rows , process visible ones

for k = 1 tsoa.databodyrange.rows.count 

and

if soawb.worksheets(1).cells(j, 4).height > 0 then... 

similar this:

for k = 1 tsoa.databodyrange.rows.count      soawb.worksheets(1)          if tsoa.databodyrange(k, 6).height > 0              .cells(j, 4) = tsoa.databodyrange(k, 6) 'debit amount             .cells(j, 5) = tsoa.databodyrange(k, 7) 'credit amt             .cells(j, 1) = tsoa.databodyrange(k, 3) 'date             .cells(j, 2) = right(tsoa.databodyrange(k, 3), 2) & "-" & _                                 tsoa.databodyrange(k, 2) 'reference number             select case tsoa.databodyrange(k, 1)                 case "inv": .cells(j, 3) = "invoice"                 case "cr":  .cells(j, 3) = "credit"                 case else:  msgbox "invalid type"             end select         end if     end     j = j + 1 next 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -