Bonsoir Game Over,
Pardon de ne répondre que maintenant, travail oblige.
Ta macro me convient parfaitement, merci beaucoup.
J'ai ajouter quelques options afin de pouvoir calculer également le taux de rotation et la couverture.
Lorsque j'applique la macro au fichier original, après 22000 lignes, la macro stoppe et une erreur de type 13 apparaît. Je ne comprend pas pourquoi? Je fournis le VB. le débogage qui apparaît ce situe sur la ligne en gras.
Sub Stock()
Dim NumProduit As Long, DerLig As Long, StockInit As Long, StockFinal As Long, Quantité As Long
Dim Mouvement As String
Application.ScreenUpdating = False
With Sheets("Mvt 12")
DerLig = .Cells(Rows.Count, 1).End(xlUp).Row
i = 2
While i <= DerLig
StockInit = .Cells(i, 8 )
StockFinal = StockInit
Do
NumProduit = .Cells(i, 1)
Mouvement = .Cells(i, 9)
Quantité = .Cells(i, 10)
Select Case Mouvement
Case "S"
StockFinal = StockFinal - Cells(i, 10)
Sumquantite = Sumquantite + Cells(i, 10)
Case Else
StockFinal = StockFinal + Cells(i, 10)
End Select
i = i + 1
Loop Until NumProduit <> .Cells(i, 1)
Cells(i - 1, 11) = (StockInit + StockFinal) / 2 'Stock moyen
If Cells(i - 1, 11) <> 0 Then
Cells(i - 1, 12) = Sumquantite / Cells(i - 1, 11) 'Taux de rotation
If Sumquantite <> 0 Then
Cells(i - 1, 13) = Cells(i - 1, 11) / (Sumquantite / 12) 'Couverture
End If
End If
Sumquantite = 0
Wend
End With
Application.ScreenUpdating = True
End Sub
Est-il possible que cela ce produise car il y a des nombres décimaux?
Cordialement.