问题
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