Mise en fome automatique dans formulaire VBA

  • Initiateur de la discussion Initiateur de la discussion Antho35
  • Date de début Date de début

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 !

Antho35

XLDnaute Occasionnel
Bonjour,

J'ai créer un formumaire VBA. Je voudrais que les données saisie ce mettent drectement en majuscule. Ci joint un petit bout du VBA en Quesion.
 
Re : Mise en fome automatique dans formulaire VBA

Oupps un oubli,

Code:
private Sub CheckBox1_Click()
Sheets("SYNTHESE_AUTRES").Range("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
HTML:
[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]
Code:
Private Sub CommandButton2_Click()
anuleoperation2.Show
End Sub
Code:
Private Sub TextBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("01234567879", Chr(KeyAscii)) = 0 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) = 1 And tx > 3 Then TextBox4 = "0" & tx & "/": tx = TextBox4
If Len(tx) = 2 Then
If tx > 0 And tx < 32 Then
tx = tx & "/"
TextBox4 = tx
Else
TextBox4 = ""
End If
End If
If Len(tx) = 4 And Mid(tx, 4, 1) > 1 Then TextBox4 = Mid(tx, 1, 3) & "0" & Right(tx, 1) & "/20": tx = TextBox4
If Len(tx) = 5 Then
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(TextBox4, 3)
End If
End If
If Len(TextBox4) = 10 Then
End If
End Sub
Code:
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox5 = "" Then Exit Sub
On Error Resume Next
TextBox5 = Format(TextBox5, "00:00")
End Sub
Code:
Private Sub TextBox5_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("01234567879", Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Code:
Private Sub TextBox5_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Len(TextBox5) = 2 Then TextBox5 = TextBox5 & ":": Exit Sub
End Sub
Code:
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("01234567879", Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Code:
Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 8 Then Exit Sub
tx = TextBox2.Text
If Len(tx) = 1 And tx > 3 Then TextBox2 = "0" & tx & "/": tx = TextBox2
If Len(tx) = 2 Then
If tx > 0 And tx < 32 Then
tx = tx & "/"
TextBox2 = tx
Else
TextBox2 = ""
End If
End If
If Len(tx) = 4 And Mid(tx, 4, 1) > 1 Then TextBox2 = Mid(tx, 1, 3) & "0" & Right(tx, 1) & "/20": tx = TextBox2
If Len(tx) = 5 Then
If Right(tx, 2) < 13 And Right(tx, 2) > 0 Then
If Not IsDate(tx & "/2000") Then TextBox2 = "": Exit Sub
tx = tx & "/20"
TextBox2 = tx
Else
TextBox2 = Left(TextBox1, 3)
End If
End If
If Len(TextBox2) = 10 Then
End If
End Sub
 
Re : Mise en fome automatique dans formulaire VBA

Bonjour Antho35,

Sans avoir ton formulaire sous les yeux, voici une proposition qui me semble répondre à ta demande :

Code:
Private Sub TextBox1_Change()
  TextBox1 = UCase(TextBox1)
End Sub

Bien sûr, à toi d'adapter en fonction du nom de tes contrôles.

Espérant avoir répondu.

Cordialement.
 
- 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

Réponses
1
Affichages
234
Réponses
32
Affichages
2 K
Réponses
3
Affichages
211
  • Question Question
Microsoft 365 Excel graphique
Réponses
3
Affichages
352
Retour