bonjour,
une proposition
Sub aargh()
With Sheets("feuil1")
dl = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To dl
If .Cells(i, "F") < 0 Then
m = m - .Cells(i, "F")
prod = .Cells(i, 2)
Else
If m > 0 Then
If .Cells(i, 2) = prod Then
.Cells(i, "E") = .Cells(i, "D") + m
Else
m = 0
End If
End If
End If
Next i
End With
End Sub
La macro se base sur le nom d'article et non sur le code article pour déterminer s'il s'agit du même article.
La macro traite également 2 nombres négatifs ou plus pour un même article.