|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub zz()
Dim d1 As New Dictionary, d2 As New Dictionary, d3 As New Dictionary, arr
arr = Sheet4.Range("A1").CurrentRegion
For i = 2 To UBound(arr)
d1(arr(i, 7)) = ""
d2(arr(i, 2)) = Array(arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5), arr(i, 6))
d3(arr(i, 2) & arr(i, 7)) = d3(arr(i, 2) & arr(i, 7)) + arr(i, 8)
Next
With Sheet1
.[g1].Resize(1, d1.Count) = d1.keys
.[b2].Resize(d2.Count, 5) = Application.Rept(d2.items, 1)
For i = 2 To d2.Count + 1
For j = 7 To d1.Count + 6
.Cells(i, j) = d3(.Cells(i, 2).Value & .Cells(1, j).Value)
Next
Next
End With
End Sub
|
|