[英]Run-time error '1004: PasteSpecial method of Range class failed
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.当我尝试将 Range("A1:Q20") 中的合并单元格从工作簿的一个工作表粘贴到单元格“F20”中另一个工作簿的另一个工作表中时,出现此错误,如下面的代码所示。
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'.但是,这仅粘贴不是我的意图的值,我尝试了其他 PasteSpecial 类型,例如 xlPasteAllUsingSourceTheme 等,但这些类型将返回错误'运行时错误'1004:范围 class 的 PasteSpecial 方法失败'。
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?如何将我想要的合并单元格粘贴到另一个工作簿的另一个工作表中?
Your With
blocks are not actually doing anything at the moment.您的
With
块目前实际上并没有做任何事情。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.