請教各位前輩,為何新增到第10筆就會,錯誤,超出範圍,謝謝.
Sub 按鈕1_Click()
Set d = CreateObject("Scripting.Dictionary")
a = [a1].CurrentRegion
For i = 1 To UBound(a)
k = a(i, 1) & a(i, 2)
If Not d.exists(a(i, 1) & a(i, 2)) Then
d(k) = Application.Index(a, i)
Else
d(k) = Array(d(k)(1), d(k)(2), d(k)(3), d(k)(4) + a(i, 4))
End If
Next
'[a9].Resize(d.Count, 4) = Application.Transpose(Application.Transpose(d.items))
[f1].Resize(d.Count, 4) = Application.Transpose(Application.Transpose(d.items))
'Range("a" & x).Resize(d.Count, 4) = Application.Transpose(Application.Transpose(d.items))
End Sub