VBA pasteFormats激活目标工作表

时间:2017-03-06 08:09:14

标签: vba excel-vba excel-2013 excel

我在粘贴列时遇到问题

    Set SourceWBsht = Thisworkbook.Worksheets("Source")
    Set DestinationWBsht= Thisworkbook.Worksheets("Destination")
    SourceWBsht.Range("A1:Z40").EntireColumn.Copy
    DestinationWBsht.Range("A1:Z40").EntireColumn.PasteSpecial  _
    Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    SourceWBsht.Range("A1:Z40").EntireRow.Copy
    DestinationWBsht.Range("A1:Z40").EntireRow.PasteSpecial _
    Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

问题是VBA自动激活目标表,不知何故,我试图避免它。有什么想法吗?

感谢。

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

 DestinationWBsht.Range("A1:Z40").value = SourceWBsht.Range("A1:Z40").value

编辑1:评论后

SourceWBsht.Range("A1:Z40").Copy
DestinationWBsht.Range("A1:Z40").PasteSpecial xlPasteFormats
Application.CutCopyMode = False