Copy and Paste between Workbooks

beginvbaanalyst

Board Regular
Joined
Jan 28, 2020
Messages
139
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

Please help.
I'm wanting to open a closed workbook with a macro, then make the variable, then set the variable, then copy from a separate (already open) workbook and paste into the new set workbook. How do I do this correctly?
I keep getting this error.
1594416501944.png

My current vba is the following:
VBA Code:
Sub OpenAddClubsScript()

Workbooks.Open Filename:="A:\Scripts Library\WSM3_Listing_Template_9.17.18.xlsx"
Dim ListScript As Workbook

'Prompt Sheet1[LIST]
'Workbooks("ListScript").Activate
Set ListScript = Sheets("LIST") 'set sheet for formula

'With LISTARTICLES.Range("A2", LISTARTICLES.Range("A" & Rows.Count).End(xlUp)).Copy LIST.Range("A" & Rows.Count).End(xlUp).Offset(1)



End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Just from looking with the naked eye you have listscript as a workbook object, but you are saying it's the worksheet. I would suggest using

Set wb = ThisWorkbook

Then get the sheet you want using wb.worksheet("List")
 
Upvote 0
Not sure if this is what you mean, it might help you a bit.
VBA Code:
Sub OpenAddClubsScript()

    ' make some variables
    Dim LISTARTICLES    As Worksheet    ' source
    Dim oShtDest        As Worksheet    ' destination

    ' set some variables
    Set LISTARTICLES = ThisWorkbook.Sheets("LIST")
    Set oShtDest = Workbooks.Open(Filename:="A:\Scripts Library\WSM3_Listing_Template_9.17.18.xlsx").ActiveSheet

    ' perform copy from source sheet to destination sheet
    LISTARTICLES.Range("A2", LISTARTICLES.Range("A" & Rows.Count).End(xlUp)).Copy oShtDest.Range("A" & Rows.Count).End(xlUp).Offset(1)

End Sub
 
Upvote 0
Not sure if this is what you mean, it might help you a bit.
VBA Code:
Sub OpenAddClubsScript()

    ' make some variables
    Dim LISTARTICLES    As Worksheet    ' source
    Dim oShtDest        As Worksheet    ' destination

    ' set some variables
    Set LISTARTICLES = ThisWorkbook.Sheets("LIST")
    Set oShtDest = Workbooks.Open(Filename:="A:\Scripts Library\WSM3_Listing_Template_9.17.18.xlsx").ActiveSheet

    ' perform copy from source sheet to destination sheet
    LISTARTICLES.Range("A2", LISTARTICLES.Range("A" & Rows.Count).End(xlUp)).Copy oShtDest.Range("A" & Rows.Count).End(xlUp).Offset(1)

End Sub
I think this is EXACTLY what I'm looking for.
I will try in the morning and let you know if this works.
Fingers crossed
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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