|
Public Sub test()
Application.ScreenUpdating = False
Dim dic As Object, arr, i, sht As Worksheet
arr = Sheet1.UsedRange
Set dic = CreateObject("scripting.dictionary")
For i = 4 To UBound(arr)
If Not dic.exists(arr(i, 25)) Then
dic(arr(i, 25)) = arr(i, 9)
Else
dic(arr(i, 25)) = dic(arr(i, 25)) + arr(i, 9)
End If
Next
For Each k In dic.keys
Set sht = Sheets.Add(After:=Sheets(Sheets.Count))
sht.Name = k
sht.Range("a1").Value = arr(2, 25)
sht.Range("b1").Value = arr(2, 9)
sht.Range("a2").Value = k
sht.Range("b2").Value = dic(k)
Next
Sheet1.Activate
Set dic = Nothing
Application.ScreenUpdating = True
End Sub |
|