0

i want to copy a range of cells of a particular row and column number to specific worksheet of a workbook.

Sub test()
Dim x As Workbook
Dim y As Workbook
Set x = Workbooks("Book4.xlsx")
Set y = Workbooks("Book5.xlsx")
y.Worksheets("Sheet1").Range("A1:A5").Paste = x.Worksheets("Sheet1").Range(Cells(1, 1), Cells(1, 5)).Copy
End Sub
pts
  • 1
  • 2
    You got the **Copy >> Paste** a little mixed-up, use `x.Worksheets("Sheet1").Range(Cells(1, 1), Cells(1, 5)).Copy Destination:= y.Worksheets("Sheet1").Range("A1:A5")`. If you want to copy only the values, then use: `y.Worksheets("Sheet1").Range("A1:A5").Value = x.Worksheets("Sheet1").Range(Cells(1, 1), Cells(1, 5)).Value` – Shai Rado Feb 28 '17 at 06:22
  • you can simplify it to `x.Worksheets("Sheet1").Range("A1:A5").Copy y.Worksheets("Sheet1").Range("A1")` since Excel will extend the pasted area accordingly to the copied one – user3598756 Feb 28 '17 at 06:34
  • http://stackoverflow.com/a/34886033/4539709 – 0m3r Feb 28 '17 at 07:04

0 Answers0