尝试找到一个代码来更改控件 V 函数以粘贴为值
当我使用下面的代码时,我需要更改控件 V 以始终粘贴为值;
Public Sub PasteValue()
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
除非我尝试从网页使用它,否则它会返回 400 错误或 1004 错误。我已经能够弄清楚如何从网页或工作簿中粘贴为值,但不能同时粘贴两者。
任何帮助将不胜感激。
谢谢' 肖恩
I need to change control V to always paste as values, when I use the below code;
Public Sub PasteValue()
Selection.PasteSpecial Paste:=xlPasteValues
End Sub
This works except when I try and use it from a web page, it either returns a 400 error or 1004 error. I have been able to figure out how to paste as values from a web page or from within the workbook but not both.
Any help would be appreciated.
Thanks'
Shaune
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上不是一个选择。
粘贴特殊值保留用于从 Excel 复制和粘贴到 Excel。其全部要点是将单元格中公式的结果复制到另一个或同一单元格的文本/数字表示形式,以便删除对公式的引用。
如果您尝试直接在 Excel 中执行此操作,您将得到以下结果...
复制 ->选择性粘贴 ->来自网页的值
这是您将看到的选项,无法粘贴特殊值,因为一切都是值。这只是您想要从源数据应用什么格式的问题。
复制->选择性粘贴 ->范围内的值
您可以在此处获得该选项,因为复制的源是一系列单元格。
这需要增强,这样你才能得到你想要的东西,但你应该能够用这样的东西来满足这两种情况......
This is actually not an option.
Paste Special Values is reserved for copying and pasting from Excel to Excel. The whole point of it is to copy a result from a formula in a cell to it's textual/numerical representation to another or the same cell so as to remove the reference on the formula.
If you try and do this in Excel directly, you'll get this result ...
Copy -> Paste Special -> Values from a Web Page
This is the option you will see, there is no ability to paste special values because everything is a value. It's just a matter of what formatting you want to apply from the source data.
Copy -> Paste Special -> Values from a Range
This is where you get the option because the source being copied from is a range of cells.
This will need to be enhanced so you get exactly what you want but you should be able to cater for both scenarios with something like this ...