Dùng thử code này xem sao.
Sub ABC()
Dim i&, j&, t&, k&, tong&, lr&
Dim Arr(), KQ()
With Sheets("data")
lr = .Cells(Rows.Count, 1).End(xlUp).Row
Arr = .Range("A1:D" & lr).Value
tong = Application.Sum(.Range("D2:D" & lr))
End With
ReDim KQ(1 To tong + 1, 1 To 3)
k = 1
KQ(k, 1) = Arr(1, 1)
KQ(k...