Avec la partie du code cela devrait être sans doute plus pratique
Dim lign, lign1, lign2 As Integer
Dim com, com1 As Range, recherche, recherche1 As Range
Dim val, val1 As String
Dim i As Integer
Dim Sum
Dim Diamètre, Normal As String
Set recherche = Sheets("Stock").Range("F3:F2000")
val = ListBox1.Value
Set com = recherche.Cells.Find(what:=val, LookAt:=xlWhole)
Sheets("Stock").Unprotect "stockmno"
If com Is Nothing Then
MsgBox "Impossible d'effectuer la sortie"
Else
lign1 = com.Row
Set recherche1 = Sheets("Stock").Range("D" & lign1)
val1 = ListBox2.Value
Set com1 = recherche1.Cells.Find(what:=val1, LookAt:=xlWhole)
If com1 Is Nothing Then
MsgBox "Le numéro de coulée: " & ListBox1.Value & " et le diamètre: " & ListBox2.Value & " ne correspondent pas"
Else
If quantité1.Value = "" Then
MsgBox ("Saisir une quantité....")
Else
If MsgBox("Etes vous sur de vouloir effectuer la sortie de: " & quantité1.Value & "Kg, N°de coulée :" & ListBox1.Value & ", Diamètre: " & ListBox2.Value & " ?", vbYesNo) = vbYes Then
Worksheets("Stock").Range("E" & lign1).Value = Worksheets("Stock").Range("E" & lign1).Value - quantité1.Value
'--------------------------------------------------------------------------------
With Sheets("Stock")
Normal = .Range("C" & lign1).Value
Diamètre = .Range("D" & lign1).Value
i = .Range("C65536").End(xlUp).Row
Sum = Application.SumProduct((.Range(.Cells(4, 3), .Cells(i, 3)) = Normal) * (.Range(.Cells(4, 4), .Cells(i, 4)) = Diamètre) * (.Range(.Cells(4, 5), .Cells(i, 5))))
MsgBox Sum
End With
'-------------------------------------------------------------------------------------------------------
Sheets("Stock").Protect "stockmno"
If Worksheets("Stock").Range("E" & lign1).Value < 0 Then
MsgBox "Erreur de stock, valeur négative", vbExclamation
End
End If
End
End If
End If
End If
End If
End Sub