|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
如果没有不良品记录,上面的代码出错- 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
- If d.Count Then
- 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
- Else
- Exit Sub
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|