参与一下
Sub 统计()
Dim arr, brr, myrow, i, j, d As Object
Set d = CreateObject("Scripting.Dictionary")
With Sheets("sheet1")
myrow = .Cells(Rows.Count, 1).End(3).Row
arr = [a1].Resize(myrow, 2)
ReDim brr(1 To myrow, 1 To 3)
For i = 2 To myrow
s = arr(i, 1) & "/" & arr(i, 2)
If Not d.exists(s) Then
m = m + 1
d(s) = m
brr(m, 1) = arr(i, 1)
brr(m, 2) = arr(i, 2)
brr(m, 3) = 1
Else
j = d(s)
brr(j, 3) = brr(j, 3) + 1
End If
Next i
[d2:f10000].ClearContents
[d1].Resize(, 3) = [{"表箱类型","表箱型号","表箱数量"}]
[d2].Resize(m, 3) = brr
[d1].CurrentRegion.Borders.LineStyle = 1
End With
Set d = Nothing
End Sub |