VBA pasteFormats activating the destination worksheet

柔情痞子 提交于 2019-12-08 12:39:21

问题


I have a problem with pasting columns

    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

The problem is VBA activating the destination sheet automatically, Somehow, I am trying to avoid it. Any ideas?

Thanks.


回答1:


You can try something like this:

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

Edit 1: After Comment

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


来源:https://stackoverflow.com/questions/42620502/vba-pasteformats-activating-the-destination-worksheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!