0
votes

I have this error when I try to paste a merged cell within the Range("A1:Q20") from one worksheet of a workbook into another worksheet of another workbook in the cell "F20" as seen in the code below.

With ActiveWorkbook.Sheets("Data")
Range("A1:Q20").Copy
dataworkbook.Close
End With

With ActiveWorkbook.Sheets("Destination Data")
Range("F20").PasteSpecial xlPasteAll
End With

However, this pastes only values which is not my intention, I have tried other PasteSpecial types such as xlPasteAllUsingSourceTheme etc, but these types would return the error 'Run-time error '1004: PasteSpecial method of Range class failed'.

What could have caused this error in this context?

Any how do I paste my desired merged cells into another worksheet of another workbook exactly the same?

1

1 Answers

0
votes

Your With blocks are not actually doing anything at the moment. Your code could be simplified to just:

ActiveWorkbook.Sheets("Data").Range("A1:Q20").Copy Destination:=Workbooks("other workbook name.xlsx").Sheets("Destination Data").Range("F20")
dataworkbook.Close