|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub qq()
- Dim d, r&, i&, ar, s$, aa, bb, br, m&, s1, i1%
- Set d = CreateObject("Scripting.Dictionary")
- r = Cells(Rows.Count, 1).End(xlUp).Row
- ar = Range("a2:g" & r)
- For i = 1 To UBound(ar)
- If Len(ar(i, 6)) Then
- s = ar(i, 1) & "+" & ar(i, 2) & "+" & ar(i, 3) & "+" & ar(i, 4)
- If Not d.exists(s) Then
- Set d(s) = CreateObject("Scripting.Dictionary")
- End If
- d(s)(ar(i, 6)) = d(s)(ar(i, 6)) + ar(i, 7)
- End If
- Next
- ReDim br(1 To d.Count, 1 To 5)
- m = 0
- For Each aa In d.keys
- m = m + 1
- For Each bb In d(aa).keys
- br(m, 5) = br(m, 5) & "," & bb & "*" & d(aa)(bb)
- Next
- br(m, 5) = Mid(br(m, 5), 2)
- s1 = Split(aa, "+")
- For i1 = 1 To 4: br(m, i1) = s1(i1 - 1): Next
- Next
- With Sheets("报表")
- .[a1].CurrentRegion.Offset(1).ClearContents
- .[a2:e2].Resize(d.Count) = br
- .Activate
- End With
- End Sub
复制代码 |
|