第九个例子:By 'zax010- Sub zz()
- Dim d1, d2, ar
- Set d1 = CreateObject("Scripting.Dictionary")
- Set d2 = CreateObject("Scripting.Dictionary")
- ar = [a1].CurrentRegion
- For i = 3 To UBound(ar)
- d1(ar(i, 1) & "-" & ar(i, 2)) = d1(ar(i, 1) & "-" & ar(i, 2)) & "," & ar(i, 3) & "," & ar(i, 4) & "," & ar(i, 5) & "," & ar(i, 6)
- d2(ar(i, 1) & "-" & ar(i, 2)) = d2(ar(i, 1) & "-" & ar(i, 2)) + ar(i, 4)
- Next
- For Each k In d1.keys
- Cells(17 + n, 1).Resize(1, 2) = Split(k, "-")
- Cells(17 + n, 3) = d2(k)
- s = Split(Mid(d1(k), 2), ",")
- Cells(17 + n, 4).Resize(1, UBound(s) + 1) = s
- n = n + 1
- Next
- End Sub
复制代码
|