试了一下按彭兄比楼主的快10倍! Sub tiger744990() Dim dic As Object, arr, arr1, i%, j%, n% Dim aa As Double aa = Timer Application.ScreenUpdating = False Set dic = CreateObject("Scripting.Dictionary") n = Cells(65536, 1).End(xlUp).Row arr = [a1].CurrentRegion.Value ReDim temp(1 To 10000, 1 To 7) For i = 2 To n If Not dic.exists(arr(i, 2) & arr(i, 3)) Then x = x + 1 dic.Add arr(i, 2) & arr(i, 3), x temp(x, 1) = arr(i, 1) temp(x, 2) = arr(i, 2) temp(x, 3) = arr(i, 3) temp(x, 4) = arr(i, 4) temp(x, 5) = arr(i, 5) temp(x, 6) = arr(i, 6) temp(x, 7) = arr(i, 7) Else u = dic(arr(i, 2) & arr(i, 3)) temp(u, 5) = temp(u, 5) + arr(i, 5) temp(u, 6) = temp(u, 6) + arr(i, 6) temp(u, 7) = temp(u, 7) + arr(i, 7) End If Next Sheet2.[a1:g1] = Sheet1.[a1:g1].Value Sheet2.[a2].Resize(10000, 7) = temp Set dic = Nothing Application.ScreenUpdating = True MsgBox "Total:= " & Format(Timer - aa, "0.00") & "s" End Sub |