Copy data from entire column into specific table

scorziello

New Member
Joined
Jun 11, 2021
Messages
16
Office Version
  1. 2016
Platform
  1. Windows
I am trying to copy data from Sheet2 column G to Table1 Column3 on Sheet1. Here is the code I have so far but keep getting an error
VBA Code:
Sub moveStuff()
Dim lr As Long
lr = Sheets("Sheet1").Cells(Rows.Count, "G").End(xlUp).Row
Sheets("Sheets1").Range("G2:G" & lr).Copy Sheets("Sheet2").ListObjects("Table5").ListColumns(3)
End Sub
 
Yeah, it gets through everything and errors out on that line. This is exactly the code I am running, with your debug added in.
VBA Code:
Sub ClearColumns()
    Dim lr As Long
    
    Debug.Print Sheets("Sheet1").Name
    Debug.Print Sheets("Sheet2").Name
    Debug.Print Sheets("Sheet1").ListObjects("Table5").ListColumns(3).DataBodyRange.Address
    
    lr = Sheets("Sheet2").Cells(Rows.Count, "G").End(xlUp).Row

    Sheets("Sheets2").Range("G2:G" & lr).Copy Sheets("Sheet1").ListObjects("Table5").ListColumns(3).DataBodyRange.Cells(1)
    
End Sub
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I feel so dumb that I missed that s on Sheets2. Thank you for your help!!
 
Upvote 0
I didn't specifically mention it but I had changed Sheets to Sheet in my code and assumed that you would copy/paste my code to test. ;)
Anyway, main thing is that you got it sorted in the end. :)
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
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