VBA: Copying data from another opened workbook to the current workbook

donatepresent

New Member
Joined
Oct 4, 2017
Messages
21
Hi Everyone,

I need help figuring out how to copy a fixed data range from another Workbook with a fixed file name (i.e. COA.xlms) and paste to the current/master/active Workbook that does not have a fixed file name(dynamic). Both Workbook will already be open, but the problem for me is how to get the copied data back to the current/master/active Workbook that the VBA is running on.

Thanks,
Ken
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi Ken,

As per my understanding you want to copy the fixed data range from COA.xlms in another file (the file name can be different).

Is my understanding correct ?

Thanks,
Saurabh
 
Upvote 0
Hi Ken,

As per my understanding you want to copy the fixed data range from COA.xlms in another file (the file name can be different).

Is my understanding correct ?

Thanks,
Saurabh
Copy fixed data range from COA.xlms to the main Workbook that can have different file name.
 
Upvote 0
Is the code in the workbook you want to copy to?
Also what are the sheet names & the range to be copied?
 
Upvote 0
Is the code in the workbook you want to copy to?
Also what are the sheet names & the range to be copied?
In my personal macro, so yes the code is ran on the master workbook and I want to copy from another workbook COA.xlms with sheet name "Budget" and Range A1:I36.
 
Upvote 0
Is the code in the master workbook, or your in your personal.xlsb workbook?
 
Upvote 0
Because it depends on how the code is written. It would be easier & safer if the code was in the master workbook.
How about
VBA Code:
Sub donatepresent()
   With ActiveWorkbook.Sheets("Sheet1")
      Workbooks("COA.xlsm").Sheets("Budget").Range("A1:I36").Copy .Range("A1")
   End With
End Sub
The master workbook must be the activeworkbook when the code is run. Change Sheet1 to suit.
 
Upvote 0
Solution
Because it depends on how the code is written. It would be easier & safer if the code was in the master workbook.
How about
VBA Code:
Sub donatepresent()
   With ActiveWorkbook.Sheets("Sheet1")
      Workbooks("COA.xlsm").Sheets("Budget").Range("A1:I36").Copy .Range("A1")
   End With
End Sub
The master workbook must be the activeworkbook when the code is run. Change Sheet1 to suit.

The sheet I want it to apply to is Sheet5, so I changed Sheet1 to Sheet5, but I don't see the copy and paste data from COA.xlsm. Also, I want the paste to go in cell "I3" of Sheet5.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

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