Good afternoon,
After loads of googling I can't solve the problem I'm having.
I want to (as the title states) copy data from one table to another where the second table is on a separate sheet. In the case where there is already data in the second table, I want to wipe out the table and paste in the data from table 1.
As it stands, my code is working to clear table 2, but that's it.
Help please. Code is below. Thanks!
After loads of googling I can't solve the problem I'm having.
I want to (as the title states) copy data from one table to another where the second table is on a separate sheet. In the case where there is already data in the second table, I want to wipe out the table and paste in the data from table 1.
As it stands, my code is working to clear table 2, but that's it.
Help please. Code is below. Thanks!
Code:
Sub testingsStuff()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheets("Growing Location Editor")
Set ws2 = Sheets("growing_location_commits")
source = "Table1"
destination = "Table2"
'clearing contents of table 2
ws2.Activate
ActiveSheet.ListObjects(destination).DataBodyRange.Delete
'copy data from table 1
ws1.Activate
ActiveSheet.ListObjects(source).DataBodyRange.Copy
'paste data into table 2 - I know that .Paste isn't an option, but I kept it there to make clear what I want to do
ws2.Activate
ActiveSheet.ListObjects(destination).DataBodyRange.Cells(1, 1).Paste
End Sub