[英]Copy and paste Excel Macro
I have a macro I use for pasting in excel it works fine except when copy and pasting from one cell to another. 我有一个宏用于在excel中粘贴,除了从一个单元格复制并粘贴到另一个单元格外,它工作正常。 In other words it works fine with say text from a webpage but not from one cell to another.
换句话说,它适用于网页中的说文本,但不适用于从一个单元格到另一个单元格的文本。 The error message says
Run time error '1004': PasteSpecial method of Worksheet class failed.
该错误消息显示
Run time error '1004': PasteSpecial method of Worksheet class failed.
Here is the code: 这是代码:
Sub MousePaste()
'
' MousePaste Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
ActiveCell.Select
ActiveSheet.PasteSpecial Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
End Sub
There are two implementations of a PasteSpecial method. PasteSpecial方法有两种实现。
Worksheet.PasteSpecial which pastes from the clipboard and Worksheet.PasteSpecial从剪贴板粘贴并
Range.PasteSpecial which pastes from/to a range. Range.PasteSpecial从/到范围进行粘贴。
You probably need the latter, examples in the above links. 您可能需要后者,即上面链接中的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.