Scripting.DictionaryªºÀ³¥Î
- ©«¤l
- 976
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 1018
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Office 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-4-19
- ³Ì«áµn¿ý
- 2024-10-30
|
¦^´_ 1# john2006168
¤£¤@¼Ë¼gªk¡A½Ð¦A´ú¸Õ¬Ý¬Ý¡AÁÂÁ¡C
Sub test2()
Dim Arr, xD, T, T2%, i&
Set xD = CreateObject("Scripting.Dictionary")
Sheets("¤u§@ªí1").Range("B1:C1").Copy Sheets("Summary").Range("A1")
Arr = Sheets("¤u§@ªí1").[a1].CurrentRegion
For i = 2 To UBound(Arr)
T = Arr(i, 2): T2 = Arr(i, 3)
xD(T & "") = xD(T & "") + T2
Next
Sheets("Summary").[A2].Resize(xD.Count) = Application.Transpose(xD.keys)
Sheets("Summary").[B2].Resize(xD.Count) = Application.Transpose(xD.items)
End Sub |
|
|
|
|
|
|
- ©«¤l
- 976
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 1018
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Office 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-4-19
- ³Ì«áµn¿ý
- 2024-10-30
|
¦^´_ 1# john2006168
½Ð¸Õ¬Ý¬Ý¡AÁÂÁ¡C
Sub test()
Dim Arr, xD, Ar(), T, T2%, i&, M%, N%
Set xD = CreateObject("Scripting.Dictionary")
Sheets("¤u§@ªí1").Range("B1:C1").Copy Sheets("Summary").Range("A1")
Arr = Sheets("¤u§@ªí1").[a1].CurrentRegion
ReDim Ar(1 To UBound(Arr), 1 To 2)
For i = 2 To UBound(Arr)
T = Arr(i, 2): T2 = Arr(i, 3)
If xD.Exists(T & "") Then
M = xD(T & "")
Ar(M, 2) = Ar(M, 2) + T2
Else
N = N + 1: xD(T & "") = N
Ar(N, 1) = T: Ar(N, 2) = T2
End If
Next
Sheets("Summary").[A2].Resize(N, 2) = Ar
End Sub |
|
|
|
|
|
|