Excel VBA减less运行时间

我正在将数据从一个工作簿复制并粘贴到另一个工作簿。 不幸的是,我不满意我的运行时间。 特别是我的代码的这一部分需要很多时间。 你有什么想法来减less运行时间?

Function CopyData() sws.Activate Range("C4:GF4").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy tws.Activate Range("A12").Select ActiveSheet.Paste Range("D12:GD12").Select Range(Selection, Selection.End(xlDown)).Select Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False End Function 

这应该会提高性能,这是@EngJon所指的关于不使用select。

 Function CopyData() Dim rng As Range Application.ScreenUpdating = False sws.Activate Range("C4:GF" & Range("GF" & Rows.Count).End(xlUp).Row).Copy tws.Activate Range("A12").PasteSpecial Paste:=xlPasteAll Set rng = Range("D12:GD" & Range("GD" & Rows.Count).End(xlUp).Row) rng.Value = rng.Value Application.ScreenUpdating = True End Function