1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Sub mise_à_jour()
Dim i As Integer, j As Integer, qte1 As Integer, qte2 As Integer, aux1 As Integer, aux2 As Integer
Dim WSfac As Worksheet, WScmd As Worksheets, WSsto As Worksheet, WSven As Worksheet
Set WSfac = Worksheets("FACTURE")
Set WScmd = Worksheets("Cmdes")
Set WSsto = Worksheets("Fstock")
Set WSven = Worksheets("Fvendeur")
For i = 6 To 11
If WSfac.Cells(5, 7) = WScmd.Cells(i, 1) Then
If WScmd.Cells(i, 12) = "oui" Then
MsgBox "cette commande a déjà été facturéé "
Exit Sub
Else
WScmd.Cells(i, 12) = "oui"
End If
End If
Next i
For i = 15 To 19
If WSfac.Cells(i, 3) <> "" Then
qte1 = WSfac.Cells(i, 5)
For j = 6 To 14
If WSsto.Cells(j, 1) = WSfac.Cells(i, 3) Then
qte2 = WSsto.Cells(j, 3)
WSsto.Cells(j, 3) = qte2 - qte1
End If
Next j
End If
Next i
For i = 6 To 8
If WSven.Cells(i, 1) = WSfac.Cells(28, 4) Then
If WSven.Cells(i, 4) = "" Then
WSven.Cells(i, 4) = WSfac.Cells(26, 4)
WSven.Cells(i, 5) = WSfac.Cells(26, 4)
Else
aux1 = WSven.Cells(i, 4)
aux2 = WSven.Cells(i, 5)
WSven.Cells(i, 4) = aux1 + WSfac.Cells(26, 4)
If aux2 > WSfac.Cells(26, 4) Then
WSven.Cells(i, 5) = WSfac.Cells(26, 4)
End If
End If
End If
Next i
End Sub |
Partager