微小的VBAmacros运行真的很慢

我写的macros运行速度很慢,不知道为什么。 macros删除该区域,然后将一列位置复制为一行,删除任何重复项,然后复制一列date,然后将相应的每个date的平均值放在正确的function位置下。

这里是代码:

Sub Macro1() ' ' Macro1 Macro ' Delete Previous Data Range("J1:AQ1000").Clear ' Functional Location Dim toAdd As Boolean, uniqueTag As Integer, i As Integer, j As Integer Cells(1, 11).Value = Cells(2, 2).Value uniqueTag = 11 toAdd = True For i = 3 To 1000 For j = 11 To uniqueTag If Cells(i, 2).Value = Cells(1, j).Value Then toAdd = False End If Next j If toAdd = True Then Cells(1, uniqueTag + 1).Value = Cells(i, 2).Value uniqueTag = uniqueTag + 1 End If toAdd = True Next i ' Date Dim k As Integer For k = 2 To 1000 Cells(k, 10).Value = Cells(k, 6).Value Next k ' Mean Value Dim l As Integer, m As Integer For l = 2 To 1000 For m = 11 To 100 If Cells(l, 2).Value = Cells(1, m).Value Then Cells(l, m).Value = Cells(l, 5).Value End If Next m Next l End Sub 

是否有任何优化可以使其运行得更快,还是我没有包括的东西? 第一部分的工作非常迅速,只有复制平均值需要时间。

在我所评论的地方插入你的代码:

 Application.Calculation = xlCalculationManual Application.ScreenUpdating = False '----enter here all of your code---- Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True