Numérotation automatique

Antho35

XLDnaute Occasionnel
Bonjour,

J'ai créer un formulaire avec ces code ci

Code:
Private Sub CheckBox1_Click()
Range("SYNTHESE_AUTRES!O65536").End(xlUp)(2).Value = IIf(CheckBox1, "X", "")
End Sub
Code:
Private Sub CheckBox2_Click()
Range("SYNTHESE_AUTRES!P65536").End(xlUp)(2).Value = IIf(CheckBox2, "X", "")
End Sub
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, 2) = ligne
'End If
Sheets("SYNTHESE_AUTRES").Cells(ligne, 2) = Format(TextBox1, "2_2010_0000")
Sheets("SYNTHESE_AUTRES").Cells(ligne, 3) = Format(TextBox2, "mm/dd/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 TextBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
 Select Case KeyAscii
    Case 44, 47 To 57      'Autorise les touches 0 à 9 et /
    Case Else
        KeyAscii = 0
    End Select
    If Len(TextBox4) = 10 Then KeyAscii = 0
End Sub
Code:
Private Sub TextBox4_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 8 Then Exit Sub
tx = TextBox4.Text
If Len(tx) = 2 Then
If KeyCode = 111 Then TextBox4 = "0" & Left(tx, 1) & "/": Exit Sub
If tx > 0 And tx < 32 Then
tx = tx & "/"
TextBox4 = tx
Else
TextBox4 = ""
End If
End If
If Len(tx) = 5 Then
If KeyCode = 111 Then TextBox4 = Left(tx, 3) & "0" & Mid(tx, 4, 1) & "/20": Exit Sub
If Right(tx, 2) < 13 And Right(tx, 2) > 0 Then
If Not IsDate(tx & "/2000") Then TextBox4 = "": Exit Sub
tx = tx & "/20"
TextBox4 = tx
Else
TextBox4 = Left(TextBox1, 3)
End If
End If
If Len(TextBox4) = 10 Then
End If
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)")
ComboBox1.AddItem "Sélectionez votre service"
ComboBox2.AddItem "Sélectionez le type de transport"
ComboBox3.AddItem "Sélectionez le lieu de RDV"
ComboBox4.AddItem "Sélectionez le motif de votre transport"
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
ComboBox1.ListIndex = 0
ComboBox2.ListIndex = 0
ComboBox3.ListIndex = 0
ComboBox4.ListIndex = 0
End Sub
Code:
Private Sub CommandButton2_Click()
anuleoperation2.Show
End Sub

Mes données vont bien alimenter mon tableaux. Le probléme que je rencontre concerne le numéo de demande qui est un num auto. dans le formulaire il se suit 1,2,3,4.... dans min tableau de synthése il prend bien le format souhaité. or je veux que ce format soit vu sur le formulaire au lieu des 1,2,3,4....

Je pense qu'il y a une légere erreur sur mon formumaire.

Merci
 

Robert

XLDnaute Barbatruc
Repose en paix
Re : Numérotation automatique

Bonjour Antho, bonjour le forum,

C'est bien gentil tout ton code mais c'est à nous de trouver ce qui va pas... Un fichier exemple serait le bienvenu !
Mais juste une remarque, car je n'ai lu que les premières lignes de ton code :
Code:
Private Sub CheckBox1_Click()
Range("SYNTHESE_AUTRES!O65536").End(xlUp)(2).Value = IIf(CheckBox1, "X", "")
End Sub
j'aurais plutôt écrit :
Code:
Private Sub CheckBox1_Click()
Sheets("SYNTHESE_AUTRES").Range("O65536").End(xlUp)(2).Value = IIf(CheckBox1, "X", "")
End Sub
Je continue malgré tout à voir si je trouve une solution à ton problème...

Edition :

Il correspond à quoi ton numero de demande ? TextBox1 ? J'ai repéré plusieurs fois l'anomalie signalée au dessus...
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 755
Messages
2 091 711
Membres
105 054
dernier inscrit
uzaoui