Data transfer between two workbooks

prathyush

Board Regular
Joined
Jan 9, 2009
Messages
60
I have two workbooks book1.xls and book2.xls

I want to load data in sheet1 of book2 to sheet1 of book1.
This sheet1 of book2 has a table of 10 rows and 10 columns.

How to do that in VBA??
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try

Code:
Sub Cpy()
Workbooks("Book2").Sheets("Sheet1").Range("A1:J10").Copy _
    Destination:=Workbooks("Book1").Sheets("Sheet1").Range("A1")
End Sub
 
Upvote 0
Try

Code:
Workbooks("Book2.xls").Sheets("Sheet1").Range("A1:J10").Copy _
    Destination:=Workbooks("Book1.xls").Sheets("Sheet1").Range("A1")
 
Upvote 0
Try

Code:
Workbooks("Book2.xls").Sheets("Sheet1").Range("A1:J10").Copy _
    Destination:=Workbooks("Book1.xls").Sheets("Sheet1").Range("A1")
yes got it...thanks alot.
but i have one doubt in the formula..
what is the use of ":" in CopyDestination:= ?
 
Upvote 0
It is just the syntax for specifying a named argument. Destination= will give an error.

Another example:

Rich (BB code):
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "Book2.xls"
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,530
Members
452,651
Latest member
wordsearch

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