参与一下。。。
- Sub ttt()
- Dim Dic As Object, x&, y&, i&, Arr, Drr, Brr
- Set Dic = CreateObject("scripting.dictionary")
- Arr = Range("a2:b" & Cells(Rows.Count, 1).End(xlUp).Row)
- Range("d8:e999").ClearContents
- Range("g8:h999").ClearContents
- For x = 1 To UBound(Arr)
- If Not Dic.exists(Arr(x, 1)) Then Set Dic(Arr(x, 1)) = CreateObject("Scripting.Dictionary")
- Dic(Arr(x, 1))(Arr(x, 2)) = 1 + Dic(Arr(x, 1))(Arr(x, 2))
- Next x
- Drr = Dic.keys
- For x = 0 To UBound(Drr)
- Cells(8 + x, 7) = Drr(x)
- Cells(8 + x, 8) = Dic(Drr(x)).Count
- Brr = Dic(Drr(x)).keys
- For y = 0 To UBound(Brr)
- i = i + 1
- Cells(i + 7, 4) = Drr(x)
- Cells(i + 7, 5) = Brr(y)
- Next y
- Next x
- End Sub
复制代码 |