需要添加粘贴特殊条件copy.destination for循环 [英] Need to add paste special condition a copy.destination for loop

查看:324
本文介绍了需要添加粘贴特殊条件copy.destination for循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列数据在书中的每个工作表中处于相同的位置,并且始终处于该位置。运行宏时,应将数据复制并添加到报表。我有一部分工作,但我需要使用一个特殊的粘贴:

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

,因为范围内有公式。我不确定在此代码中添加粘贴特殊条件,因为我使用 .Copy,Destination

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.

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


推荐答案




       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

这篇关于需要添加粘贴特殊条件copy.destination for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆