以下是原代码,统计几百千来组问题不大,但统计上万上十万组时间就很长,还不会用字典,请大佬帮忙优化一下,万分感谢! Sub 统计() Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i&, l&, n%, m%, j%, k%
For i = 0 To 100000006
[B8] = 0 + i
[A9] = 50 + n
[B9] = 50 + l
Cells([A9], 8) = m - 1
If Cells([A9], 1) = "" Then Application.ScreenUpdating = True: Exit Sub
k = 0
For j = 1 To 9
If WorksheetFunction.CountIf(Cells([A9], 1).Resize(1, 9), Cells([B9], j)) > 0 Then
k = k + 1
End If
Next j
If k > 5 Then
m = m + 1
End If
l = l + 1
If Cells([B9], 1) = "" Then
n = n + 1
m = 0
l = 0
End If
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
|