Option Explicit
Sub TEST_20230106_1()
Dim Brr, i&, T1$, T2&, TT$, Y, M$, N&, P&
Set Y = CreateObject("Scripting.Dictionary")
Brr = [A1].CurrentRegion: N = 1
For i = 2 To UBound(Brr)
T1 = Brr(i, 1): Brr(i, 1) = 0
T2 = Brr(i, 2): Brr(i, 2) = 0
TT = T1 & "|" & T2
If Len(T1) = 15 And Not Y.Exists(T1) Then
N = N + 1
Y(T1) = N
Brr(N, 1) = T1
ElseIf Y(TT) = "" Then
M = Left(T1, 15)
Brr(Y(M), 2) = Brr(Y(M), 2) + T2
P = P + T2
End If
Y(TT) = 1
Next
[E:F].ClearContents
With [E1].Resize(N, 2)
.Value = Brr
.Item(N + 1, 1) = "合計": .Item(N + 1, 2) = P
End With
Set Y = Nothing
Set Brr = Nothing
End Sub作者: aer 時間: 2023-1-6 18:55