VBA Copy Destination question

rpmitchell

New Member
Joined
Jun 22, 2011
Messages
43
Using Excel 2007.

I am trying to copy and paste in a single statement using the Copy Destination:= method. However, I'm not sure how to make it work if I'm trying to copy to an unopened workbook. Right now I'm using:

Range("C30:G30,C36:G36").Select
Selection.Copy
Workbooks.Open Filename:= _
"N:\Financial Statements\AR Days Master file.xlsm"
Sheets("Receiving sheet").Select
Range("B2").Select
ActiveSheet.Paste

I would like to shorten this by simply using the Copy Destination piece. Can anyone show me what this would look like? :confused:
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Something like this should work...

Code:
Dim thisFile As String
Dim thatFile As String
    thisFile = ActiveWorkbook.Name
    thatFile = "AR Days Master file.xlsm"
Workbooks.Open Filename:="N:\Financial Statements\" & thatFile

Windows(thisFile).Activate

Range("C30:G30,C36:G36").Copy (Windows(thatFile).RangeSelection(2, 3))
 
Upvote 0
Try
Code:
[FONT=Courier New]Dim mybook As Workbook[/FONT]
[FONT=Courier New]Set mybook = Workbooks.Open("C:\Users\Pediez\Desktop\weBook1.xlsm")[/FONT]
[FONT=Courier New]Sheet1.Range("C30:G30,C36:G36").Copy Destination:=mybook.Sheets("Sheet1").Range("B2")[/FONT]
 
Upvote 0
Re: VBA Copy Destination questio

Something like this...

set wbFrom = thisworkbook
set wbTo = Workbooks.Open(Filename:= "N:\Financial Statements\AR Days Master file.xlsm")
wbFrom.Range("C30:G30,C36:G36").Copy wbTo.Sheets("Receiving sheet".Range("B2")
 
Upvote 0
Thanks for the replies! I took the day off today, but will be back at work Monday morning and try them out. Will let you know which ones work. :)
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

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