- Sub gj23w98()
- Set d = CreateObject("Scripting.Dictionary")
- ar = Sheet1.[a1].CurrentRegion
- ReDim br(1 To UBound(ar), 1 To 28)
- cr = br
- For i = 2 To UBound(ar)
- If Len([a2]) And Len([b2]) = 0 And ar(i, 2) = [a2] Then
- s = ar(i, 1) & ar(i, 4)
- If d(s) = "" Then
- m = m + 1: d(s) = m
- br(m, 1) = ar(i, 1)
- br(m, 2) = ar(i, 4)
- For j = 7 To UBound(ar, 2)
- br(m, j - 4) = ar(i, j)
- Next
- Else
- br(d(s), 1) = ar(i, 1)
- br(d(s), 2) = ar(i, 4)
- For j = 7 To UBound(ar, 2)
- br(d(s), j - 4) = br(d(s), j - 4) + ar(i, j)
- Next
- End If
- End If
- If Len([a2]) = 0 And Len([b2]) And ar(i, 6) = [b2] Then
- s = ar(i, 3) & ar(i, 4)
- If d(s) = "" Then
- n = n + 1: d(s) = n
- cr(n, 1) = ar(i, 3)
- cr(n, 2) = ar(i, 4)
- For j = 7 To UBound(ar, 2)
- cr(n, j - 4) = ar(i, j)
- Next
- Else
- cr(d(s), 1) = ar(i, 3)
- cr(d(s), 2) = ar(i, 4)
- For j = 7 To UBound(ar, 2)
- cr(d(s), j - 4) = cr(d(s), j - 4) + ar(i, j)
- Next
- End If
- End If
- Next
- If m Then [a6:ab19] = "": [a6].Resize(m, 28) = br
- If n Then [a21:ab35] = "": [a21].Resize(n, 28) = cr
- End Sub
复制代码 |