VBA:在没有剪贴板的情况下复制粘贴
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3901045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA: Copy paste without clipboard
提问by Merlin
Is there a way to do this as one line copy/paste without using the clipboard. copy one range - row to another sheet paste range - entire row. I need values, not formula.
有没有办法在不使用剪贴板的情况下将其作为一行复制/粘贴来执行。将一个范围 - 行复制到另一个工作表粘贴范围 - 整行。我需要的是价值观,而不是公式。
Sheets("Data").Select
ActiveCell.EntireRow.Copy
Sheets("TSP").Select
ActiveCell.PasteSpecial Paste:=xlPasteValues
回答by Dr. belisarius
This code copy values (not formulas).
此代码复制值(不是公式)。
Sub a()
Worksheets("Sheet2").Range("TS").Value=Worksheets("Sheet1").Range("1:1").Value
End Sub
Where "TS" is the name of a range (one row).
其中“TS”是范围的名称(一行)。
Is this what you are trying to achieve?
这是你想要达到的目标吗?
Edit
编辑
To copy the active row to Sheet2.Row2 (for example) you may try:
要将活动行复制到 Sheet2.Row2(例如),您可以尝试:
Sub a()
Dim myrow As Integer
myrow = ActiveWindow.RangeSelection.Row
Worksheets("Sheet2").Range("2:2").Value = Worksheets("Sheet1").Rows(myrow).Value
End Sub
HTH!
哼!
回答by GSerg
For some reason, there isn't. PasteSpecial
is all about the clipboard.
出于某种原因,没有。PasteSpecial
都是关于剪贴板的。
If you only need values, make a For
loop copying them.
如果您只需要值,请For
循环复制它们。