'字典裡的陣列需要變數盛裝出來編輯,再放回字典,才有效
Option Explicit
Sub TEST()
Dim Y, i&, j&, 陣列()
Set Y = CreateObject("Scripting.Dictionary")
Set Y(1) = Range([1B!I1], [1B!A1].End(xlDown))
Y(2) = Y(1): Y(5) = 1: 陣列 = Y(2)
For i = 2 To UBound(陣列)
If 陣列(i, 4) Like "RH*" And 陣列(i, 5) = "A36" Then
Y(5) = Y(5) + 1
For j = 1 To UBound(陣列, 2)
陣列(Y(5), j) = 陣列(i, j)
Next
Y(0) = Y(0) + 陣列(Y(5), 8)
End If
Next
Y(2) = 陣列
Workbooks.Add
[A1].Resize(Y(5), UBound(Y(2), 2)) = Y(2)
Cells(Y(5) + 1, 3) = "小計"
Cells(Y(5) + 1, 8) = Y(0)
Cells.Columns.AutoFit
Set Y = Nothing: Erase 陣列
End Sub