Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

hutch57

XLDnaute Occasionnel
Bonjour le forum,

Pour mon premier userform il me faudrait un petit coup de pouce, j'ai commencé mais je bloque par endroit.

Voici mon fichier pour explication

Cdt Hutch
 

Pièces jointes

Re : Premier userform

Salut
une idée pour commencer

Private Sub CommandButton1_Click()
ws = ComboBox2.Text
If ws = "" Then Exit Sub
With Worksheets(ws).Range("A5").End(xlDown)
.Offset(1, 0).Value = TextBox1.Value
.Offset(1, 1).Value = TextBox2.Value
.Offset(1, 2).Value = TextBox3.Value
.Offset(1, 3).Value = TextBox4.Value
End With
End Sub

Private Sub UserForm_Initialize()
ComboBox2.AddItem "Scenic"
ComboBox2.AddItem "Passat"
End Sub
 
Re : Premier userform

Bonjour le forum, nantouillet, jp14

Quand je marque le kilometrage j'ai un problème avec le VBA dl1 = .Range

Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim dl1 As Long ' dernière ligne
Dim i As Byte
dl1 = .Range("a65536").End(xlUp).Row
If .Range("b" & dl1) > TextBox2.Value Then
Call MsgBox("Votre avez fait des km en marche arrière", vbInformation Or vbDefaultButton1, Application.Name)

TextBox2.Value = ""
End If
End Sub

Merci a vous deux

Cdt
 
Re : Premier userform

Bonjour (re)

Il faut modifier la procédure en ajoutant

Code:
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim dl1 As Long ' dernière ligne
Dim i As Byte
[COLOR="Red"]If ComboBox2.ListIndex = -1 Then Exit Sub
With Sheets(ComboBox2.Value)[/COLOR]
...................................
 TextBox2.Value = ""
End If
[COLOR="Red"]End With[/COLOR]
End Sub

Il faut rajouter avant "With Sheets(ComboBox2.Value)" le code
If ComboBox2.ListIndex = -1 Then Exit Sub code qui permet de vérifier si on a sélectionné un véhicule.


JP
 
Re : Premier userform

Bonjour le forum,
Merci a tous les deux jh14 et nantouillet
ce code marche impec
dl1 = Worksheets("nom de la feuille").Range("a65536").End(xlUp).Row
If Worksheets("nom de la feuille").Range("b" & dl1) > TextBox2.Value Then

C'est de l'or ce site, je vous dit a bientôt.

Cdt Hutch
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

  • Question Question
XL 2016 liste
Réponses
10
Affichages
387
Réponses
2
Affichages
187
  • Question Question
Microsoft 365 Suivi de budget
Réponses
5
Affichages
292
  • Question Question
Microsoft 365 Fonction si
Réponses
7
Affichages
223
Retour