Dear All
I have a situation where I need to copy specific columns from a table (secondary) and append them to another table (master). The 'master' table has a summary row at the bottom,
With reference to the code below I need to copy specific columns from tbl2 and paste the data into specific columns in new rows at the bottom of tbl1.
tbl2.Column2 goes to tbl1.Column4
tbl2.Column3 goes to tbl1.Column5
tbl2.Column4 goes to tbl1.Column6
tbl2.Column6 goes to tbl1.Column11
tbl2.Column7 goes to tbl1.Column12
The code performs the first 3 copies / pastes the data into new rows at the bottom of tbl1 ok. I am unsure how to expand this to copy the data from tbl1.Columns 6 and 7 and paste into tbl2.columns 11 and 12. If I repeat the Union the data is inserted into more new rows at then bottom of tbl1 where as I would like it to be inserted into the same rows created by the first paste operation.
Dim tbl1 As ListObject
Dim tbl2 As ListObject
Set tbl1 = ThisWorkbook.Worksheets("Sheet1").ListObjects("masterTable")
Set tbl2 = ThisWorkbook.Worksheets("Sheet2").ListObjects("secondaryTable")
tbl1.AutoFilter.ShowAllData
tbl1.ListRows.Add
Union(tbl2.ListColumns(2).DataBodyRange, tbl2.ListColumns(3).DataBodyRange, tbl2.ListColumns(4).DataBodyRange).Copy Destination:= _
tbl1.ListColumns(4).DataBodyRange.Offset(tbl1.DataBodyRange.Rows.Count - 1)
Set tbl1 = Nothing
Set tbl2 = Nothing
Bookmarks