My Macro that I wrote is running really slowly and I'm not sure why. The Macro deletes the area, then reproduces one column of locations as a row, deleting any duplicates, then copy's across a column of dates, then puts the corresponding Mean value for each date under the correct functional location.
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
Are there any optimizations that would make it run faster, or something I haven't included? The first parts all work pretty speedily, its only the copying of the mean values which appears to take time.