lioneldu47
XLDnaute Occasionnel
Bonjour le forum,
J'ai un petit problème de macro que je n'arrive pas à résoudre... pourtant j'ai vu plus compliqué mais il y a toujours un débogage que je ne comprend pas.Voici la macro que je voudrais modifier :
Private Sub CmbValiderretrait_Click()
ActiveSheet.Unprotect
Dim L As Long, x As Long
L = ComboRef.ListIndex + 2
If TextQuantité1 = "" Then
MsgBox " Vouse devez définir une quantité"
Exit Sub
End If
If IsNumeric(TextQuantité1) = False Then
MsgBox " Vous devez définir une quantité numérique"
Exit Sub
End If
With Sheets("Stock")
x = .Cells(L, 4) - CLng(TextQuantité1.Value)
If x < 0 Then
MsgBox "La quantité n'est pas disponible"
TextQuantité1 = ""
TextQuantité1.SetFocus
Exit Sub
End If
End With
With Sheets("Stock")
.Cells(ComboRef.ListIndex + 2, 4) = .Cells(ComboRef.ListIndex + 2, 4) - CLng(TextQuantité1.Value)
If .Cells(ComboRef.ListIndex + 2, 13) >= .Cells(ComboRef.ListIndex + 2, 4) Then
UserForm2.Show
End If
End With
Unload Me
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
La feuille stock est vérouillé donc la macro ne fonctionne pas. Je sais qu'il faut insérer: ActiveSheet.Unprotect et ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Mais je ne dois pas mettre ces bout de macro au bon endroit.
Merci pour votre aide.