ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

Scripting.DictionaryªºÀ³¥Î

¦^´_ 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

TOP

¦^´_ 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

TOP

        ÀR«ä¦Û¦b : ¯u¥¿ªº·R¤ß¡A¬O·ÓÅU¦n¦Û¤vªº³oÁû¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD