Copy range of data from one workbook to another

Dorothychin

Board Regular
Joined
Oct 7, 2002
Messages
130
Hi, I am new to macro and would like some help on this.
I have 2 workbooks having similar worksheet names and layout.
On 1st workbook, I would like select a range of data from one worksheet (eg using mouse to highlight the data range "C2:H10"), run a macro to copy the data range, go to the 2nd workbook, with the same worksheet name, and paste this data into the same range ("C2:H10").
Appreciate the help
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi there, try this but always save your workbooks before trying a new macro

Code:
Sub BookoneToBooktwo()
'Change the Book1 and Book2 names to the names of your workbooks
    Selection.Copy
Windows("Book2").Activate
    Sheets("Sheet1").Select
        Range("C2").Select
            Selection.PasteSpecial Paste:=xlPasteValues
Windows("Book1").Activate
    Sheets("Sheet1").Select
End Sub

Change in the code ~ Book1 and Book2 to the names of your workbooks.
If the worksheets are the first worksheets in both books you can leave as is, otherwise change the worksheet names to the ones you have named

The workbook you copy to must be open, if it is not open it will come up with an error.
If you wish to put it into a closed workbook the code will have to be changed.

Cheers
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,328
Members
452,907
Latest member
Roland Deschain

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