Salut ANDREMW,
ta macro de retour...
Private Sub valider_Click()
'
Dim sWk1 As Worksheet, sWk2 As Worksheet, rCel As Range
Dim Rep%, iTRow%
'
Set sWk1 = Worksheets("Mouvement fact")
Set sWk2 = Worksheets("articles")
'
On Error Resume Next
Application.EnableEvents = False
Application.ScreenUpdating = False
'
With Worksheets("facturation")
If .[B1] <> "" And .[C6] <> "" And .[G2] <> "" Then
Rep = MsgBox("Souhaitez-vous valider la facture et mettre à jour les stocks", vbYesNo + vbQuestion, "Facturation")
If Rep = 6 Then 'ligne facture
For x = 6 To .Range("C5").End(xlDown).Row
iTRow = sWk1.Range("B" & Rows.Count).End(xlUp).Row + 1
For y = 1 To 4
sWk1.Cells(iTRow, 1 + y) = Choose(y, .[B1], .[G2], .Cells(x, 4), .Cells(x, 5))
Next
Set rCel = sWk2.Columns(3).Find(what:=.Cells(x, 3), lookat:=xlWhole)
If Not rCel Is Nothing Then
sWk2.Cells(rCel.Row, 6) = sWk2.Cells(rCel.Row, 6) - .Cells(x, 5)
Else
MsgBox "L'article " & .Cells(x, 3) & " est introuvable!", vbCritical + vbOKOnly, "Facturation"
End If
Next
End If
Me.Label1.Caption = "Les stocks ont été mis à jour. La facture peut être éditée."
End If
End With
'
On Error GoTo 0
Application.ScreenUpdating = True
Application.EnableEvents = True
'
End Sub
A+