Question(s) Amélioration Userform

Antho35

XLDnaute Occasionnel
Bonjour,

J'ai créer un formulaire, ce dernier une fois enregistré, va allimenter un tableaux excel. Voici le code.

Private Sub CommandButton1_Click()
Dim ligne As Integer
ligne = ActiveCell.Row
Range("B2").Select
'If Len(Sheets("SYNTHESE_AUTRES").Cells(ligne, 2))= Then
If Range("B2").Value = "" Then
ligne = Range("SYNTHESE_AUTRES!B65500").End(xlUp).Row + 1
Else
ligne = Range("SYNTHESE_AUTRES!B65500").End(xlUp).Row + 1
End If
Sheets("SYNTHESE_AUTRES").Cells(ligne, 1) = ligne
'End If
Sheets("SYNTHESE_AUTRES").Cells(ligne, 2) = Format(TextBox1, "2_2009_0000")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 3) = Format(TextBox2, "dd/mm/yyyy")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 4) = ComboBox1.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 5) = ComboBox2.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 12) = Format(TextBox4, "dd/mm/yyyy")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 13) = Format(TextBox5, "hh:mm")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 11) = ComboBox3.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 10) = ComboBox4.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 14) = TextBox6.Value
ComboBox1 = "Sélectionnez votre service"
ComboBox2 = "Sélectionnez le type de transport"
ComboBox3 = "Sélectionnez le lieu de RDV"
ComboBox4 = "Sélectionnez le motif"
TextBox1 = Format(TextBox1, "2_2010_0000")
TextBox2 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
confirmation2.Show
End Sub
Private Sub UserForm_Initialize()
Dim Dline As Integer
Dline = Range("SYNTHESE_AUTRES!B20000").End(xlUp).Row
TextBox1.Value = Dline
TextBox2.Value = Date
ComboBox1.ColumnCount = 1
ComboBox2.ColumnCount = 1
ComboBox3.ColumnCount = 1
ComboBox4.ColumnCount = 1
With ThisWorkbook.Worksheets("UF (2)")
For I = 4 To .Range("D65536").End(xlUp).Row
autresdemandes.ComboBox1.AddItem .Range("D" & I).Value
Next I
End With
With ThisWorkbook.Worksheets("TYPE DU TRANSPORTS")
For I = 3 To .Range("C65536").End(xlUp).Row
autresdemandes.ComboBox2.AddItem .Range("C" & I).Value
Next I
End With
With ThisWorkbook.Worksheets("MOTIF")
For I = 3 To .Range("C65536").End(xlUp).Row
autresdemandes.ComboBox4.AddItem .Range("C" & I).Value
Next I
End With
With ThisWorkbook.Worksheets("LIEUX DE RDV")
For I = 3 To .Range("C65536").End(xlUp).Row
autresdemandes.ComboBox3.AddItem .Range("C" & I).Value
Next I
End With
End Sub
Private Sub CommandButton2_Click()
anuleoperation2.Show
End Sub

Mes question sont les suivantes
dans textbox1 à l'ouvertuere les chiffres suivant se mettre 1 puis aprés l'autre enregistrement 2, or je veux y voir apparaitre mon format de code c'est à dire 2_2010_0001 puis 2_2010_0002 pour le suivant, ect ect (commme indiquez).
Quand on ouvre le formulaire je vois voire dans le combob le "séléctionez votre..." il est dans le code met de met à la fin quand l'utilisateur fait ok.
Je veux que la date et l'heur se mettre en forme automatiquement dans le formulaire. si on tape 010101 ou 01/01/01 ou autre chose qu'elle deviennet 01/01/2001, idem pour l'heure que 414 devient 04:14.

Pour certains se ne sont que des détails" mais j'aime la perfection et la rigueur.
Merci pour vos solutions les amis.
 

Hpotter

XLDnaute Junior
Re : Question(s) Amélioration Userform

Bonjour,

Peux-tu remettre ton code mais avec des balises codes (#) que tu trouveras dans le bandeau en-dessous de l'intitulé.

Pour nous cela sera plus lisible. Je t'en remercie par avance
 

Hpotter

XLDnaute Junior
Re : Question(s) Amélioration Userform

Tu vois présenté comme ça c'est plus lisible pour tout le monde.

Code:
Private Sub CommandButton1_Click()
Dim ligne As Integer
ligne = ActiveCell.Row
Range("B2").Select
'If Len(Sheets("SYNTHESE_AUTRES").Cells(ligne, 2))= Then
If Range("B2").Value = "" Then
ligne = Range("SYNTHESE_AUTRES!B65500").End(xlUp).Row + 1
Else
ligne = Range("SYNTHESE_AUTRES!B65500").End(xlUp).Row + 1
End If
Sheets("SYNTHESE_AUTRES").Cells(ligne, 1) = ligne
'End If
Sheets("SYNTHESE_AUTRES").Cells(ligne, 2) = Format(TextBox1, "2_2009_0000")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 3) = Format(TextBox2, "dd/mm/yyyy")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 4) = ComboBox1.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 5) = ComboBox2.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 12) = Format(TextBox4, "dd/mm/yyyy")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 13) = Format(TextBox5, "hh:mm")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 11) = ComboBox3.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 10) = ComboBox4.Value
Sheets("SYNTHESE_AUTRES").Cells(ligne, 14) = TextBox6.Value
ComboBox1 = "Sélectionnez votre service"
ComboBox2 = "Sélectionnez le type de transport"
ComboBox3 = "Sélectionnez le lieu de RDV"
ComboBox4 = "Sélectionnez le motif"
TextBox1 = Format(TextBox1, "2_2010_0000")
TextBox2 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
confirmation2.Show
End Sub

Code:
Private Sub UserForm_Initialize()
Dim Dline As Integer
Dline = Range("SYNTHESE_AUTRES!B20000").End(xlUp).Row
TextBox1.Value = Dline
TextBox2.Value = Date
ComboBox1.ColumnCount = 1
ComboBox2.ColumnCount = 1
ComboBox3.ColumnCount = 1
ComboBox4.ColumnCount = 1
With ThisWorkbook.Worksheets("UF (2)")
For I = 4 To .Range("D65536").End(xlUp).Row
autresdemandes.ComboBox1.AddItem .Range("D" & I).Value
Next I
End With
With ThisWorkbook.Worksheets("TYPE DU TRANSPORTS")
For I = 3 To .Range("C65536").End(xlUp).Row
autresdemandes.ComboBox2.AddItem .Range("C" & I).Value
Next I
End With
With ThisWorkbook.Worksheets("MOTIF")
For I = 3 To .Range("C65536").End(xlUp).Row
autresdemandes.ComboBox4.AddItem .Range("C" & I).Value
Next I
End With
With ThisWorkbook.Worksheets("LIEUX DE RDV")
For I = 3 To .Range("C65536").End(xlUp).Row
autresdemandes.ComboBox3.AddItem .Range("C" & I).Value
Next I
End With
End Sub

Code:
Private Sub CommandButton2_Click()
anuleoperation2.Show
End Sub
 

Statistiques des forums

Discussions
312 098
Messages
2 085 265
Membres
102 844
dernier inscrit
atori2