Copy range from one workbook to another

Scandrea1

New Member
Joined
Feb 29, 2016
Messages
17
Hello all,

I have very little VBA experience, and I'm trying to copy a range from one workbook to another. From the open workbook, I want to copy cells B24:Q42 in the sheet entitled 'Questionnaire and Results'. I then want to paste these copied cells into a different workbook. That workbook's location is C:\Users\sunger\Downloads\FEDLCA_LCI_Template_v1_03.23.16.xlsm, and I want the copied cells to be pasted into cell D6 (with the other, corresponding cells filled in by the range) in the sheet entitled 'InputsOutputs'.

If anyone could produce some code that would fulfill those needs I'd really appreciate it!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi Scanddrea1,

See if this does what you are want...

Change the worksheet name if necessary where indicated.

Code:
Sub CopyPaste()


    Dim wb1 As Workbook
    Dim wb2 As Workbook


    Set wb1 = ActiveWorkbook


    'Copy what you want from workbook 1.
    wb1.Worksheets("Sheet1").Range("B24:Q42").Copy 'Change worksheet


    'Open workbook 2
    Set wb2 = Workbooks.Open("C:\Users\sunger\Downloads\FEDLCA_LCI_Template_v1_03.23.16.xlsm")


    'Paste to worksheet in workbook2:
    Application.DisplayAlerts = False
    wb2.Sheets("InputsOutputs").Range("D5").PasteSpecial
    Application.CutCopyMode = False
    Range("A1").Select


    'Close workbook
    wb2.Close savechanges:=True
    Application.DisplayAlerts = True
    
End Sub

HTH

igold
 
Upvote 0

Forum statistics

Threads
1,214,620
Messages
6,120,554
Members
448,970
Latest member
kennimack

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