Option Explicit
Sub TEST()
Dim Brr, Z, i&, j%, C%, T$
'↑宣告變數
Set Z = CreateObject("Scripting.Dictionary")
'↑令Z變數是 字典
Brr = Range([J2], [A65536].End(3))
'↑令Brr變數是 二維陣列,以A~J欄儲存格值帶入陣列中
For i = 3 To UBound(Brr)
For j = 3 To 9 Step 3
For C = j - 1 To j + 1
T = Brr(i, 1) & Brr(1, j): Z(T) = Z(T) + Brr(i, C)
Next
Next
Next
'↑設順迴圈將組合字串當key,item是 時數累加值
Brr = Range([P2], [L65536].End(3))
'↑令Brr陣列值換盛裝目標儲存格值
For i = 2 To UBound(Brr)
For j = 2 To 5
Brr(i, j) = Z(Brr(1, j) & Brr(i, 1))
Next
Next
'↑設順迴圈將Z字典中的item值吐出來給陣列
Range([P2], [L65536].End(3)) = Brr
'↑令Brr陣列值寫入儲存格中
Set Z = Nothing: Erase Brr
End Sub