vba - How to copy table rows without knowing it's containing sheet -


i want copy data 1 table another, 1 workbook another. know table names, identical. source table has unknown number of data rows plus unknown number of empty rows. destination table (same name, same sheet) has empty rows, not same overall number of rows origin.

i know can

sourcebook.activate activesheet.listobjects(knowntablename).databodyrange.select selection.copy destinationbook.activate activesheet.listobjects(knowntablename).databodyrange.select activesheet.paste 

however there number of problems:

  1. the table not on activesheet. how find sheet table on? or there better way reference (ideally without having find sheet first)?
  2. i know .activate , selection.copy slow , bad. how can better?
  3. how find "used" data range of both tables without looping through table rows?
  4. is possible copy data row row (so non empty rows copied)? ideally, insert non-empty source rows destination table , subsequently delete empty rows in destination table

to answer question 2:

dim losource listobject dim lodestination listobject  set losource = ...   'to set lodestination = ...   'to  lodestination.range(2,1).resize(losource.listrows.count, losource.listcolumns.count).value = losource.databodyrange.value 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -