How to copy from a closed workbook to active workbook using vba?

Siimo

New Member
Joined
Jan 9, 2017
Messages
12
I am trying to copy data from a closed workbook from a specific sheet and from a specific range and paste it into my active workbook but into a specific sheet starting at cell B7. I have the below code however it is only returning zeros. can anyone point me in the right direction? I will be building on this code once I can get this working properly so i will essentially want it to copy a variety of ranges from different sheets form the closed workbook and paste into specific sheets and ranges etc.

The ranges from the closed workbook are also named so if i can include that it would also make it slightly quicker.

Code:
Sub RectangleRoundedCorners6_Click()Dim mydata As String
'data location & range to copy
mydata = "='C:\[1133.xlsm]Cars'!$B$5:$Y$141" '<< change as required


'link to worksheet
With ThisWorkbook.Worksheets("1133Cars").Range("B7") '<< change as required
.Formula = mydata
'convert formula to text
.Value = .Value


End With
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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