Bonjour,
Est ce qu'on peux ajouter un msg si la quantité est insuffisante et ne pas exécuter la macro ?
Oui, voilà la modif
Sub Deduire_Quantite()
Dim f1 As Worksheet, f2 As Worksheet
Dim DerLig_f1 As Long, DerLig_f2 As Long, i As Long
Dim q As Range
Application.ScreenUpdating = False
Set f1 = Sheets("Feuil1")
Set f2 = Sheets("Feuil2")
DerLig_f1 = f1.Range("A" & Rows.Count).End(xlUp).Row
DerLig_f2 = f2.Range("E" & Rows.Count).End(xlUp).Row
For i = 2 To DerLig_f1
Lot = f1.Cells(i, "A")
Set q = f2.Range("E1:E" & DerLig_f2).Find(Lot, lookat:=xlWhole)
If Not q Is Nothing Then
If f1.Cells(i, "E") - f2.Cells(q.Row, "C") < 0 Then
MsgBox "Quantité insuffisante pour le lot " & f1.Cells(i, "A") & " déduction non réalisée"
Else
f1.Cells(i, "E") = f1.Cells(i, "E") - f2.Cells(q.Row, "C")
End If
End If
Next i
Set q = Nothing
Set f1 = Nothing
Set f2 = Nothing
End Sub
Cdlt