Private Sub B2_Click() ' Contrôle pour les données obligatoires Bouton Ajouter.
Dim R As Range
If ComboBox1 = "" And T1 = "" Then
ComboBox1.BackColor = &H8080FF
MsgBox "Saisissez un produit !", vbCritical, "Attention..."
ComboBox1.BackColor = &H80000005
ComboBox1.SetFocus
Exit Sub
End If
For n = 0 To 5
With Me("T" & Array(1, 2, 3, 4, 5, 6)(n))
If .Value = "" Then
.BackColor = &H8080FF
MsgBox "Saisie obligatoire !", vbCritical, "Attention..."
.BackColor = &H80000005
Me("T" & (n)).SetFocus
Exit Sub
End If
End With
Next
'Ajout
L = IIf(Dl = 2, 3, Dl + 1)
Set R = Cells(L, 1)
R = L - 2
For n = 1 To 6
R(1, n + 1) = Me("T" & n)
Next
R(1, 4) = Format(T4, "#,##0.00 €")
If MsgBox("Votre produit a été enregistré." + Chr(10) + "Désirez-vous enregistrer un autre produit ? ", vbQuestion + vbYesNo + vbDefaultButton2, _
"Enregistrement suivant") = vbNo Then Unload Me: Exit Sub
Range("B1500").End(xlUp).Offset(1, 0).Select ' Se place sur la dernière ligne
B6_Click ' Bouton Fermer
End Sub