|
- Sub test1()
- Dim r As Long, i As Long, j As Long
- Dim arr As Variant, xm As Variant, xx As Variant
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- With Worksheets("導出所有基礎資料2-0")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("A2:E" & r).Value
- For i = 1 To UBound(arr)
- xm = Split(arr(i, 5), "/")
- For j = 0 To UBound(xm)
- xx = Split(xm(j), ":")
- If d.Exists(xx(0)) Then
- d(xx(0)) = d(xx(0)) + Val(xx(1))
- Else
- d.Add xx(0), Val(xx(1))
- End If
- Next j
- Next i
- Dim keysArr As Variant, itemsArr As Variant
- keysArr = d.Keys
- itemsArr = d.Items
- .Range("J1").Resize(d.Count, 2).Value = Application.Transpose(Array(keysArr, itemsArr))
- End With
- End Sub
复制代码 |
|