- ©«¤l
- 2025
- ¥DÃD
- 13
- ºëµØ
- 0
- ¿n¤À
- 2053
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- Office2007
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_¥«
- µù¥U®É¶¡
- 2011-3-2
- ³Ì«áµn¿ý
- 2024-3-14
|
¦^´_ 4# pipi1968
§A¥Ø«e°}¦C«Å§i¤è¦¡¥i¥H°Ñ¦Ò Sub ex2()
Sub ex()
Set d = CreateObject("Scripting.Dictionary")
ar = Array(Array("AA", "yes", "Cr", 111, 222), _
Array("BB", "No", "Dr", 333, 444), _
Array("CC", "yes", "Bl", 111, 222), _
Array("AA", "yes", "Cr", 222, 333), _
Array("CC", "yes", "Bl", 333, 555), _
Array("CC", "yes", "Bl", 222, 111), _
Array("BB", "No", "Dr", 444, 222))
For i = LBound(ar) To UBound(ar)
If Not d.exists(ar(i)(0)) Then
d(ar(i)(0)) = ar(i)
Else
a = d(ar(i)(0))
a(3) = a(3) + ar(i)(3)
a(4) = a(4) + ar(i)(4)
d(ar(i)(0)) = a
End If
Next
[a1].Resize(7, 5) = Application.Transpose(Application.Transpose(ar))
[a9].Resize(d.Count, 5) = Application.Transpose(Application.Transpose(d.Items))
End Sub
Sub ex2()
Set d = CreateObject("Scripting.Dictionary")
ar = [A1:E7]
For i = LBound(ar) To UBound(ar)
If Not d.exists(ar(i, 1)) Then
d(ar(i, 1)) = Array(ar(i, 1), ar(i, 2), ar(i, 3), ar(i, 4), ar(i, 5))
Else
a = d(ar(i, 1))
a(3) = a(3) + ar(i, 4)
a(4) = a(4) + ar(i, 5)
d(ar(i, 1)) = a
End If
Next
' [a1].Resize(7, 5) = Application.Transpose(Application.Transpose(ar))
[a13].Resize(d.Count, 5) = Application.Transpose(Application.Transpose(d.Items))
End Sub |
|