Validation impossible si TextBox pas remplie
Résolu
ti_mouton
Messages postés
143
Date d'inscription
Statut
Membre
Dernière intervention
-
ti_mouton Messages postés 143 Date d'inscription Statut Membre Dernière intervention -
ti_mouton Messages postés 143 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai un Userform dans lequel je souhaiterais intégrer la condition suivante: si la TextBox1 n'est pas remplie on ne peut pas valider la saisie. Je suis très débutante en VBA, je ne sais pas donc pas trop quoi écrire et où l'insérer.
Merci pour votre aide.
J'ai un Userform dans lequel je souhaiterais intégrer la condition suivante: si la TextBox1 n'est pas remplie on ne peut pas valider la saisie. Je suis très débutante en VBA, je ne sais pas donc pas trop quoi écrire et où l'insérer.
Dim f Private Sub ComboBox6_Change() End Sub Private Sub Label1_Click() End Sub Private Sub Label2_Click() End Sub Private Sub Label3_Click() End Sub Private Sub Label4_Click() End Sub Private Sub Label5_Click() End Sub Private Sub Label6_Click() End Sub Private Sub Label7_Click() End Sub Private Sub TextBox1_Change() End Sub Private Sub TextBox2_Change() End Sub Private Sub UserForm_Initialize() Set f = Sheets("BDD") Set mondico = CreateObject("Scripting.Dictionary") For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row) mondico(C.Value) = "" Next C temp = mondico.keys Call Tri(temp, LBound(temp), UBound(temp)) Me.ComboBox1.List = temp End Sub Private Sub ComboBox1_click() Me.ComboBox2.Clear Me.ComboBox3.Clear Me.ComboBox4.Clear Me.ComboBox5.Clear Set mondico = CreateObject("Scripting.Dictionary") For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row) If C = Me.ComboBox1 Then mondico(C.Offset(, 1).Value) = "" Next C temp = mondico.keys Call Tri(temp, LBound(temp), UBound(temp)) Me.ComboBox2.List = temp End Sub Private Sub ComboBox2_click() Me.ComboBox3.Clear Me.ComboBox4.Clear Me.ComboBox5.Clear Set mondico = CreateObject("Scripting.Dictionary") For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row) If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 Then mondico(C.Offset(, 2).Value) = "" Next C temp = mondico.keys Call Tri(temp, LBound(temp), UBound(temp)) Me.ComboBox3.List = temp End Sub Private Sub ComboBox3_click() Me.ComboBox4.Clear Me.ComboBox5.Clear Set mondico = CreateObject("Scripting.Dictionary") For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row) If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 Then mondico(C.Offset(, 3).Value) = "" Next C temp = mondico.keys Call Tri(temp, LBound(temp), UBound(temp)) Me.ComboBox4.List = temp End Sub Private Sub ComboBox4_click() Me.ComboBox5.Clear Set mondico = CreateObject("Scripting.Dictionary") For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row) If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 And C.Offset(, 3).Value = Me.ComboBox4 Then mondico(C.Offset(, 4).Value) = "" Next C temp = mondico.keys Call Tri(temp, LBound(temp), UBound(temp)) Me.ComboBox5.List = temp End Sub Sub Tri(a, gauc, droi) ' Quick sort ref = a((gauc + droi) \ 2) g = gauc: d = droi Do Do While a(g) < ref: g = g + 1: Loop Do While ref < a(d): d = d - 1: Loop If g <= d Then temp = a(g): a(g) = a(d): a(d) = temp g = g + 1: d = d - 1 End If Loop While g <= d If g < droi Then Call Tri(a, g, droi) If gauc < d Then Call Tri(a, gauc, d) End Sub Private Sub CommandButton1_Click() Dim DerLig As Integer With Worksheets("Saisie") DerLig = .Range("B" & Rows.Count).End(xlUp).Row + 1 .Range("C" & DerLig).Value = ComboBox1.Value .Range("D" & DerLig).Value = ComboBox2.Value .Range("E" & DerLig).Value = ComboBox3.Value .Range("F" & DerLig).Value = ComboBox4.Value .Range("G" & DerLig).Value = ComboBox5.Value .Range("B" & DerLig).Value = ComboBox6.Value .Range("H" & DerLig).Value = TextBox1.Value .Range("K" & DerLig).Value = TextBox2.Value End With Unload UserForm1 End Sub
Merci pour votre aide.
A voir également:
- Validation impossible si TextBox pas remplie
- Ethernet n'a pas de configuration ip valide - Guide
- Cette valeur ne correspond pas aux restrictions de validation des données pour cette cellule ✓ - Forum MacOS
- Pb retour sur site marchand après validation du paiement - Forum Consommation & Internet
- Excel validation des données liste - Guide
- Temps validation annonce le bon coin - Forum Réseaux sociaux
1 réponse
Bonjour,
Ici peut être :
Ici peut être :
Private Sub CommandButton1_Click() Dim DerLig As Integer If TextBox1 = "" Then Exit Sub '!!!!!! ICI With Worksheets("Saisie") DerLig = .Range("B" & Rows.Count).End(xlUp).Row + 1 .Range("C" & DerLig).Value = ComboBox1.Value .Range("D" & DerLig).Value = ComboBox2.Value .Range("E" & DerLig).Value = ComboBox3.Value .Range("F" & DerLig).Value = ComboBox4.Value .Range("G" & DerLig).Value = ComboBox5.Value .Range("B" & DerLig).Value = ComboBox6.Value .Range("H" & DerLig).Value = TextBox1.Value .Range("K" & DerLig).Value = TextBox2.Value End With Unload UserForm1 End Sub
ti_mouton
Messages postés
143
Date d'inscription
Statut
Membre
Dernière intervention
Super, ca marche! et si je veux rajouter un MsgBox "Merci de remplir le champ Description" ?
pijaku
Messages postés
12263
Date d'inscription
Statut
Modérateur
Dernière intervention
2 761
>
ti_mouton
Messages postés
143
Date d'inscription
Statut
Membre
Dernière intervention
Tu voudrais pas que je t'invite à manger en plus?
ti_mouton
Messages postés
143
Date d'inscription
Statut
Membre
Dernière intervention
Parfait ! merci beaucoup