答案 0 :(得分:1)
尝试使用这个简单的宏作为示例:
Sub qwerty()
Dim N As Long, i As Long, K As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
K = 2
For i = 2 To N
v = Cells(i, 1)
tot = Cells(i, 2)
pack = Cells(i, 3)
While tot > 0
Cells(K, 4) = v
Cells(K, 5) = pack
tot = tot - pack
If tot < pack Then
Cells(K + 1, 5) = tot
Cells(K + 1, 4) = v
tot = 0
End If
K = K + 1
Wend
Next i
End Sub