简体   繁体   English

运行时错误'1004:范围 class 的 PasteSpecial 方法失败

[英]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.

相关问题 运行时错误'1004':Range类的PasteSpecial方法失败 - Run-time error '1004': PasteSpecial method of Range class failed 间歇性“运行时错误‘1004’范围 class 的 PasteSpecial 方法失败 - Intermittent "Run-time error '1004' PasteSpecial method of Range class failed 运行时错误1004的问题:Range Class的PasteSpecial方法失败 - Issue with a run-time error 1004: PasteSpecial method of Range Class failed excel 2010 返回:运行时错误“1004”:“Range 类的 PasteSpecial 方法失败 - excel 2010 returning: Run-time error '1004': "PasteSpecial method of Range class failed 代码突然停止运行运行时错误“1004”范围 class 的 PasteSpecial 方法失败 - Code suddenly stopped working Run-Time Error "1004" PasteSpecial method of Range class failed 运行时错误“1004”:尝试将具有匹配条件的行从一个表复制到另一个表时,范围 class 的 PasteSpecial 方法失败 - Run-time error '1004' : PasteSpecial method of Range class failed when attempting to copy a row with matching criteria from one table to another 运行时错误'1004:范围类的小计方法失败 - Run-time error '1004: Subtotal method of range class failed 运行时错误“1004”:范围类的自动过滤方法失败 - run-time error '1004': Autofilter method of range class failed 运行时错误'1004-Range类的AutoFilter方法失败 - Run-Time error '1004 - AutoFilter method of Range class failed 运行时错误1004 - 范围类的自动过滤方法失败 - Run-time error 1004 - Autofilter Method of Range Class Failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM