Premier userform

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

  • Userf.zip
    24 KB · Affichages: 58
  • Userf.zip
    24 KB · Affichages: 58
  • Userf.zip
    24 KB · Affichages: 58

nantouillet

XLDnaute Nouveau
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
 

jp14

XLDnaute Barbatruc
Re : Premier userform

Bonjour hutch57, le fil

Ci joint le fichier avec les procédures pour l'userform et quelques modifications.

A tester

JP
 

Pièces jointes

  • Userf.zip
    26.4 KB · Affichages: 72
  • Userf.zip
    26.4 KB · Affichages: 73
  • Userf.zip
    26.4 KB · Affichages: 74

hutch57

XLDnaute Occasionnel
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
 

jp14

XLDnaute Barbatruc
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
 

hutch57

XLDnaute Occasionnel
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
 

Discussions similaires

Réponses
2
Affichages
320
Réponses
2
Affichages
184

Membres actuellement en ligne

Statistiques des forums

Discussions
312 305
Messages
2 087 084
Membres
103 459
dernier inscrit
Arnocal