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 50 51 52 53 54 55 56 57 58 59 60
| Private Sub cmdValider_Click()
Dim Quantite As Variant
Dim Client As String
Dim LastLig As Long, Lig As Long
Dim LastCol As Integer, Col As Integer
Dim Produit As String
Dim Compteur As Single
Dim ComValable As String
Sheets("Commande").Select
Client = Label2.Caption
Produit = ListBox1.List(Compteur)
If ListBox1.Selected(Compteur) = False Then
MsgBox "Vous devez d'abord sélectionner les produits dans la colonne de gauche", vbCritical + vbOKOnly, " Produit non sélectionné"
Exit Sub
Call cmdValider_Click
End If
For Compteur = 0 To (ListBox1.ListCount - 1)
If ListBox1.Selected(Compteur) = True Then
With Sheets("Commande")
LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
Set c = .Range(.Cells(3, 3), .Cells(3, LastCol)).Find(Client, lookat:=xlWhole)
If Not c Is Nothing Then
Col = c.Column 'La Colonne
Set c = Nothing
LastLig = .Cells(.Rows.Count, 1).End(xlUp).Row
Set r = .Range("A4:A" & LastLig).Find(Produit, lookat:=xlWhole)
If Not r Is Nothing Then
Lig = r.Row 'La Ligne
Set r = Nothing
Quantite = InputBox("Combien de " & UCase(Produit) & Chr(10) & " commandée par " & Client, "Indication des quantités", Quantité)
If Quantite = "" Then
MsgBox "Vous devez indiquer une quantité", vbCritical + vbOKOnly, "Quantité non idiquée"
Quantite = InputBox("Combien de " & UCase(Produit) & Chr(10) & " commandée par " & Client, "Indication des quantités", Quantité)
End If
.Cells(Lig, Col).Value = Quantite
End If
End If
End With
End If
Next Compteur
autreclient = MsgBox("Autre inscription ou modification de client ?", vbQuestion + vbYesNoCancel + vbDefaultButton1, "Inscription d'un autre client")
If autreclient = vbYes Then
For Compteur = 0 To (ListBox1.ListCount - 1)
ListBox1.Selected(Compteur) = False
Next Compteur
cmdValider.Visible = False
Label2.Visible = False
Label2.Caption = ""
Label3.Visible = False
Action = MsgBox("Selon le cas, (re)cliquez sur 'nouveau client' ou sur 'modification client'", vbOKOnly, "Poursuite des commandes")
ElseIf autreclient = vbNo Or vbCancel Then
MsgBox "Vous allez pouvoir consulter le bon de commande." & Chr(10) & Chr(10) & "Regardez-le attentivement puis cliquez sur la petite croix rouge en haut à droite et, enfin, sur l'écran suivant, répondez à la question posée.", vbOKOnly, "Vérification des commandes Première étape"
Application.ScreenUpdating = False
Unload Me
Unload UserFormEC
Worksheets("Commande").PrintPreview
Application.ScreenUpdating = True
UserForm1.Show
Exit Sub
End If |
Partager