copy and paste

k_babb

Board Regular
Joined
Mar 28, 2011
Messages
71
Hi can someone help with this macro all i want to do is copy all of sheet 2 in wb1 open an excel file wb2 and paste into wb2 the problem is wb2 has headers in it so i want to paste every column starting at row 2 here is the code i have so far works fine up till the paste part


Code:
Sub copysheet()
Static wb2path As String: wb2path = Application.GetOpenFilename("excel files, *.xls*")
Static wb1 As Workbook: Set wb1 = ActiveWorkbook
Static wb2 As Workbook: Set wb2 = Workbooks.Open(wb2path)

wb1.Activate
  Sheets("Sheet2").Select
    Cells.Select
    Selection.Copy
    wb2.Activate
    Sheets("Sheet1").Cells(2, 1).Select
    ActiveSheet.Paste
 
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try

Code:
wb1.Sheets("Sheet2").UsedRange.Copy Destination:=wb2.Sheets("Sheet1").Cells(2, 1)
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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