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
| Private Sub CommandButton1_Click()
'doucle click bouton ajouter
Dim F As Worksheet
Set F = Sheets("Feuil1")
If ComboBox1 = "" Then MsgBox ("Code vide")
If TextBox2 = "" Then MsgBox ("Libellé vide")
If TextBox3 = "" Then MsgBox ("Date vide")
If TextBox4 = "" Then MsgBox ("Valeur Vide")
If TextBox5 = "" Then MsgBox ("Quantité vide")
If TextBox6 = "" Then MsgBox ("Fournisseur vide")
Dim ligne As Long
Dim plage As Range
COMPARE = ComboBox1.Value
Set c = F.Columns("A").Find(COMPARE, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
MsgBox ("Attention, vous avez entré un doublon !!!voir ligne numéro : " & c.Row)
Exit Sub
Else
If MsgBox("confirmez-vous l'ajout des données?", vbYesNo, "confirmation") = vbYes Then
Worksheets("Feuil1").Select
ligne = F.Range("A65000").End(xlUp).Row
ligne = ligne + 1
Cells(ligne, 1) = ComboBox1.Value
Cells(ligne, 2) = TextBox2.Value
Cells(ligne, 3) = TextBox3.Value
Cells(ligne, 4) = TextBox4.Value
Cells(ligne, 5) = TextBox5.Value
Cells(ligne, 6) = TextBox6.Value
End If
End If
Unload UserForm1
UserForm1.Show
End Sub |