本帖最后由 LMY123 于 2018-6-26 11:48 编辑
字典分类汇总- Sub zzC()
- Dim arr, d
- Set d = CreateObject("scripting.dictionary")
- arr = Range("d2:i" & Cells(Rows.Count, 1).End(3).Row)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- d(arr(i, 1)) = Array(arr(i, 1), arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5), arr(i, 6))
- Else
- d(arr(i, 1)) = Array(arr(i, 1), arr(i, 2), _
- d(arr(i, 1))(2) + arr(i, 3), d(arr(i, 1))(3) + arr(i, 4), d(arr(i, 1))(4) + arr(i, 5), d(arr(i, 1))(5) + arr(i, 6))
- End If
- Next
- t = Application.Transpose(Application.Transpose(d.items))
- [l2].Resize(d.Count, UBound(t, 2)) = t
- End Sub
复制代码
|