Dim pprod As String
Sub Bouton2_QuandClic()
Dim ddate As Date
Dim op As String
Dim ffournisseur As String
Dim vvaleur As Integer
pprod = Range("b4").Value
op = Range("b5").Value
vvaleur = Range("b6").Value
ddate = Format(Range("b7").Value, "dd/mm/yyyy")
vdiff = Range("b10").Value
ffournisseur = Range("b8").Value
If op = "" Or vvaleur = 0 Or ddate = 0 Or pprod = "" Or ffournisseur = "" Then
MsgBox ("Toutes les zones doivent être renseignées")
Exit Sub
End If
Select Case op
Case "Commande"
rep2 = MsgBox("Vous allez mettre à jour les commandes, Voulez vous continuer ?", vbYesNo)
If rep2 = vbYes Then
Range("b5:b6").ClearContents
Worksheets("Commande").Range("a1").Activate
Cells.Find(What:=pprod, After:=ActiveCell, LookIn:=xlValues, _
lookat:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row, 2).Value = ddate
Cells(ActiveCell.Row, 3).Value = vvaleur
Cells(ActiveCell.Row, 4).Value = "Non"
Call maj(ddate, pprod, op, vvaleur, ffournisseur)
End If
Case "Inventaire"
If message1 = 0 Then Exit Sub
Cells(ActiveCell.Row, 6).Value = vvaleur
lili1 = ActiveCell.Row
lili2 = ActiveCell.Row + 151
Call maj(ddate, pprod, op, vvaleur, ffournisseur)
Case "Entrée"
If message1 = 0 Then Exit Sub
Cells(ActiveCell.Row, 6).Value = Cells(ActiveCell.Row, 6).Value + vvaleur
lili1 = ActiveCell.Row
lili2 = ActiveCell.Row + 151
Call maj(ddate, pprod, op, vvaleur, ffournisseur)
Case "Sortie"
If message1 = 0 Then Exit Sub
Cells(ActiveCell.Row, 6).Value = Cells(ActiveCell.Row, 6).Value - vvaleur
lili1 = ActiveCell.Row
lili2 = ActiveCell.Row + 151
Call maj(ddate, pprod, op, vvaleur, ffournisseur)
End Select
Worksheets(2).Select
End Sub
Private Function message1()
message1 = 0
rep = MsgBox("Vous allez mettre à jour le stock, Voulez vous continuer ?", vbYesNo)
If rep = vbYes Then
Range("b5:b6").ClearContents
Worksheets("Produits Référencés").Select
Cells.Find(What:=pprod, After:=Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
message1 = 1
End If
End Function
Private Sub maj(£ddate As Date, £pprod As String, £op As String, £vvaleur As Integer, £ffournisseur As String)
'date produits mouvement quantité fournisseur-service
Dim dl1 As Long ' dernière ligne
With Sheets("Mouvements quotidiens")
dl1 = .Range("b65536").End(xlUp).Row + 1
.Range("b" & dl1) = £ddate
.Range("c" & dl1) = £pprod
.Range("d" & dl1) = £op
.Range("e" & dl1) = £vvaleur
.Range("f" & dl1) = £ffournisseur
End With
End Sub
Sub Bouton2_QuandClic2()
pprod = Range("b4").Value
op = Range("b5").Value
vvaleur = Range("b6").Value
ddate = Range("b7").Value
vdiff = Range("b10").Value
ffournisseur = Range("b8").Value
If op = "" Or vvaleur = "" Or ddate = "" Or pprod = "" Or ffournisseur = "" Then
MsgBox ("Toutes les zones doivent être renseignées")
Exit Sub
End If
If op <> "Commande" Then
rep = MsgBox("Vous allez mettre à jour le stock, Voulez vous continuer ?", vbYesNo)
If rep = vbYes Then
Range("b5:b6").ClearContents
Worksheets("Produits Référencés").Select
Cells.Find(What:=pprod, After:=Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If op = "Inventaire" Then
Cells(ActiveCell.Row, 6).Value = vvaleur
lili1 = ActiveCell.Row
lili2 = ActiveCell.Row + 151
End If
If op = "Entrée" Then
Cells(ActiveCell.Row, 6).Value = Cells(ActiveCell.Row, 6).Value + vvaleur
lili1 = ActiveCell.Row
lili2 = ActiveCell.Row + 151
End If
If op = "Sortie" Then
Cells(ActiveCell.Row, 6).Value = Cells(ActiveCell.Row, 6).Value - vvaleur
lili1 = ActiveCell.Row
lili2 = ActiveCell.Row + 151
End If
End If
Worksheets(2).Select
Else
rep2 = MsgBox("Vous allez mettre à jour les commandes, Voulez vous continuer ?", vbYesNo)
If rep2 = vbYes Then
Range("b5:b6").ClearContents
Worksheets("Commande").Select
Range("a1").Activate
Cells.Find(What:=pprod, After:=ActiveCell, LookIn:=xlValues, _
lookat:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells(ActiveCell.Row, 2).Value = ddate
Cells(ActiveCell.Row, 3).Value = vvaleur
Cells(ActiveCell.Row, 4).Value = "Non"
End If
End If
End Sub
Sub Bcomm_QuandClic()
Range("d3:d500").Select
For Each cece In Selection
If cece.Value = "Oui" Then
dquant = Cells(cece.Row, cece.Column - 1).Value
ddate = Range("b1").Value
dprod = Cells(cece.Row, cece.Column - 3).Value
lili1 = cece.Row - 1
lili2 = cece.Row + 500 - 1
Worksheets("Produits Référencés").Select
Cells(lili1, 6).Value = Cells(lili1, 6).Value + dquant
Worksheets("Commande").Select
Cells(cece.Row, cece.Column - 2).ClearContents
Cells(cece.Row, cece.Column - 1).ClearContents
Cells(cece.Row, cece.Column).ClearContents
End If
Next
Range("a1").Select
End Sub