VBA: Copy/Paste Data Between Tables

zero269

Board Regular
Joined
Jan 16, 2023
Messages
219
Office Version
  1. 365
Platform
  1. Windows
Hello,

I've been looking at ways to automate copying data from a Table in one Sheet to another Table on another Sheet.

VBA looks like the way to go, but I'm not well versed on decoding VBA to make sense to build or fully edit to achieve my goal.

I normally add a new row at the end of the Table on Sheet2, then Copy and Paste > Values into that new row which expands automatically.

I will later purge those Copied rows from the old table, but for now, If I can automate the Copy/Paste, that would be very helpful.

Using my Sample Workbook, I would like to Copy all of the Rows in a Table tbl_BooksSource

Copy From:
Sheet1: Import
Table: tbl_BooksSource
Columns: D thru N only
Rows: All (except Heading)
Note: Columns A - C are not part of the table.


Copy To:
Sheet2: Books
Table: tbl_Books
Copy (append) to end of Table


Any guidance would be greatly appreciated…
 

Attachments

  • 1674368136484.png
    1674368136484.png
    8.8 KB · Views: 27
  • 1674368136487.png
    1674368136487.png
    20 KB · Views: 29
Oops I only looked at the previous code samples which all have D2:N2.
Copying the whole table is actually easier. Just replace the ListRows(1) line with the one below it here:-

Rich (BB code):
' Copy from Source to Destination
'tblSource.ListRows(1).Range.Copy tblrowNew.Range
tblSource.DataBodyRange.Copy tblrowNew.Range
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top