vba 需要添加粘贴特殊条件一个 copy.destination for 循环
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10597988/
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
Need to add paste special condition a copy.destination for loop
提问by Alistair Weir
I have a range of data that is in the same position in every worksheet in a book and will always be in that position. When the macro is run the data should be copied and added to a report sheet. I have that part working but I need to use a paste special:
我有一系列数据,它们在一本书的每个工作表中都处于相同的位置,并且将始终处于该位置。运行宏时,应复制数据并将其添加到报告表中。我有那部分工作,但我需要使用特殊的粘贴:
.PasteSpecial xlPasteValues
as there are formulas in the range. I am unsure where to add the paste special condition in this code, since I'm using .Copy, Destination
.
因为范围中有公式。我不确定在此代码中的何处添加粘贴特殊条件,因为我使用的是.Copy, Destination
.
Option Explicit
Sub CreateTempPSDReport()
Dim WS As Worksheet, Rept As Worksheet
Set Rept = Sheets("Temporary PSD Report")
Application.ScreenUpdating = False
'--> Loop through each worksheet except the report and
'--> Copy the set range to the report
For Each WS In ThisWorkbook.Worksheets
If Not WS.Name = "Temporary PSD Report" Then
WS.Range("A42", "I42").Rows.Copy _
Destination:=Rept.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
Next
Application.ScreenUpdating = True
End Sub
采纳答案by Siddharth Rout
I need to use a paste special: WS.Range("A42", "I42").Rows.Copy _ Destination:=Rept.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
I need to use a paste special: WS.Range("A42", "I42").Rows.Copy _ Destination:=Rept.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
In such a case you do not use the above method. You use this
在这种情况下,您不要使用上述方法。你用这个
WS.Range("A42", "I42").Rows.Copy
Rept.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False