Problème VBA EXCEL
Résolu
LANGAZOU
Messages postés
95
Date d'inscription
Statut
Membre
Dernière intervention
-
LANGAZOU Messages postés 95 Date d'inscription Statut Membre Dernière intervention -
LANGAZOU Messages postés 95 Date d'inscription Statut Membre Dernière intervention -
A voir également:
- Cancel = true vba
- Acronis true image - Télécharger - Sauvegarde
- True crypt - Télécharger - Chiffrement
- Excel compter cellule couleur sans vba - Guide
- True launch bar - Télécharger - Divers Utilitaires
- Find vba - Astuces et Solutions
2 réponses
Bonjour,
Un début de réponse avec l'événement _Exit des textbox :
Un début de réponse avec l'événement _Exit des textbox :
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsNumeric(TextBox1) Then MsgBox "Valeur non numérique" TextBox1 = "" Cancel = True Exit Sub End If If TextBox2 = "" Then Exit Sub If Val(TextBox1) > Val(TextBox2) Then MsgBox "Borne Min > Borne Max" TextBox1 = "" Cancel = True End If End Sub Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If Not IsNumeric(TextBox2) Then MsgBox "Valeur non numérique" TextBox2 = "" Cancel = True Exit Sub End If If Val(TextBox1) > Val(TextBox2) Then MsgBox "Borne Min > Borne Max" TextBox1.SetFocus End If End Sub
je veux lorsque le textbox1 est vide et le textbox 2 non vide le EXIT sur le textbox2 me renvoie au textbox1 pour remplissage. j'ai essayé le code suivant mais ca marche pas:
Le paramètre Cancel sert à autoriser (ou interdire) la sortie du Textbox. En mettant Cancel = True dans l'événement Exit du TextBox2 tu empêche la sortie...
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 = "" Then MsgBox " Borne Min vide !" Cancel = True End If End sub
Le paramètre Cancel sert à autoriser (ou interdire) la sortie du Textbox. En mettant Cancel = True dans l'événement Exit du TextBox2 tu empêche la sortie...
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 = "" Then MsgBox " Borne Min vide !" TextBox1.SetFocus End If End sub
j'ai essayé mais le set focus n'a pas marché il se jette directement sur le textbox 3 !!
voici mon code complet:
voici mon code complet:
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox2 Mod 500 <> 0 Then TextBox2 = "" Cancel = True End If If Val(TextBox1) > Val(TextBox2) Then MsgBox "Borne Min > Borne Max" TextBox17.SetFocus End If If TextBox1 = "" Then MsgBox " Borne Min vide !" TextBox1.SetFocus End If End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 = "" Then Cancel = False Exit Sub End If If TextBox1 Mod 500 <> 0 Then TextBox1 = "" Cancel = True End If If TextBox2 = "" Then Exit Sub End If If Val(TextBox1) > Val(TextBox2) Then MsgBox "Borne Min > Borne Max" TextBox1 = "" Cancel = True End If End Sub
Bonjour,
1- pour poster du code ici, place le entre les balises codes prévues à cet effet. Mode d'emploi.
2- Tu m'étonnes que le SetFocus ne fonctionne pas... Tu attribues le Focus au TextBox17... Relis toi!
3- teste ce code :
1- pour poster du code ici, place le entre les balises codes prévues à cet effet. Mode d'emploi.
2- Tu m'étonnes que le SetFocus ne fonctionne pas... Tu attribues le Focus au TextBox17... Relis toi!
3- teste ce code :
Dim DejaPasse As Boolean 'cette ligne doit être en entête de ton Module, pas en plein milieu!!! Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean) If DejaPasse Then Exit Sub DejaPasse = False If TextBox2 = "" Then MsgBox "Borne max vide !" Cancel = True End If If TextBox1 = "" Then MsgBox "Borne Min vide !" DejaPasse = True TextBox1.SetFocus End If If Val(TextBox1) > Val(TextBox2) Then MsgBox "Borne Min > Borne Max !" DejaPasse = True TextBox1 = "" TextBox1.SetFocus End If If TextBox2 Mod 500 <> 0 Then TextBox2 = "" Cancel = True End If End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 = "" Then Cancel = True Exit Sub End If If TextBox1 Mod 500 <> 0 Then TextBox1 = "" Cancel = True End If If TextBox2 = "" Then Exit Sub End If If Val(TextBox1) > Val(TextBox2) Then MsgBox "Borne Min > Borne Max" TextBox1 = "" Cancel = True End If End Sub
Merci beaucoup pour votre aide, ca marche très bien et désolé pour le retard.
à trés bientôt.