- Sub 字典练习()
- Dim d As New Dictionary
- Dim brr() As String
- Dim crr() As String
- Dim frr
- Dim hrr
- arr = Sheet3.Range("a2", Cells(Rows.Count, 5).End(xlUp))
- For i = 2 To UBound(arr)
- If d.Exists(arr(i, 1)) Then
- d(arr(i, 1)) = Array(arr(i, 1), arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5) + d(arr(i, 1))(3))
- Else
- d(arr(i, 1)) = Array(arr(i, 1), arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5))
- End If
- Next
- t = d.Items
- t = WorksheetFunction.Transpose(WorksheetFunction.Transpose(d.Items))
- ReDim brr(1 To UBound(t))
- For j = 1 To UBound(t)
- brr(j) = Join(Array(t(j, 1), t(j, 2), t(j, 3), t(j, 4), t(j, 5)), "|")
- Next
- crr = Filter(brr, Sheet3.Range("p1"))
- ReDim frr(1 To UBound(crr) + 1)
- For k = 0 To UBound(crr)
- frr(k + 1) = Split(crr(k), "|")
- Next
- hrr = Application.WorksheetFunction.Transpose(frr)
- End Sub
复制代码 |