1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Private Sub CommandButton2_Click()
Dim X As String
Dim I As Long
X = UserForm1.ComboBox1.Value
If ComboBox1.Value = "" Or ComboBox2.Value = "" Or TextBox1.Value = "" Or TextBox2.Value = "" Or ComboBox3.Value = "" Then
MsgBox ("Veuillez remplir tous les champs pour continuer")
Exit Sub
End If
If MsgBox("Etes-vous certain de vouloir enregistrer ces nouveaux données ?", vbYesNo + vbInformation, "Demande de confirmation") = vbYes Then
With Sheets(X)
I = Sheets(X).Range("A" & Rows.Count).End(xlUp).Row
.Range("A" & I + 1).Value = ComboBox2.Value
.Range("B" & I + 1).Value = TextBox1.Value
.Range("C" & I + 1).Value = CDbl(TextBox2.Value)
.Range("D" & I + 1).Value = ComboBox3.Value
End With
End If
ComboBox1.Value = ""
ComboBox2.Value = ""
TextBox1.Value = ""
TextBox2.Value = ""
ComboBox3.Value = ""
End Sub |
Partager