Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

format 12:00 = 00:00

  • Initiateur de la discussion Initiateur de la discussion Mitch
  • 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 !

Mitch

XLDnaute Occasionnel
Bonsoir j'ai beau chercher sur le forum je trouve pas , j'ai un combobox avec des heures en menu deroulant qui fonctionne bien a par que si je saisi 12:00 il m'affiche 00:00
voici le code
Private Sub ComboBox4_Change()
ComboBox4.Value = Format(ComboBox4.Value, "hh:mm")
End Sub
je pense que c'est le format qui est de 12h et non 24h mais ou le changer
 
Dernière édition:
Re : format 12:00 = 00:00

Bonjour,

perso, ne mettrais pas ce code dans l'événement "change" du combo qui se déclenche sur chaque caractères mais plutôt dans l'événement "exit"...
Code:
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox4.Value = Format(ComboBox4.Value, "hh:mm")
End Sub
bonne journée
@+
 
Re : format 12:00 = 00:00

voici la macro si ça peut aider
Private Sub OKButton_Click()
Dim P As Integer

' S'assure que planning est active
Sheets("planning").Activate

' S'assure qu'un nom est renseigné
If ComboBox2.Text = "" Then
MsgBox "Vous devez renseigner un Nom."
ComboBox2.SetFocus
Exit Sub
End If

' S'assure qu'une equipe est renseignée
If ComboBox3.Text = "" Then
MsgBox "Vous devez renseigner une équipe."
ComboBox3.SetFocus
Exit Sub
End If

' S'assure qu'une heure de début est renseignée
If ComboBox4.Text = "" Then
MsgBox "Vous devez renseigner l'heure de début."
ComboBox4.SetFocus
Exit Sub
End If

' S'assure qu'une heure de fin est renseignée
If ComboBox5.Text = "" Then
MsgBox "Vous devez renseigner l'heure de fin."
ComboBox5.SetFocus
Exit Sub




End If
ActiveSheet.Unprotect ("wt01oks3")
P = Sheets("planning").Range("B65536").End(xlUp).Row + 1
Sheets("planning").Range("B" & P).Value = ComboBox2.Value
Sheets("planning").Range("G" & P).Value = ComboBox3.Value
Sheets("planning").Range("C" & P).Value = CDate(Me.DTPicker1.Value)
Sheets("planning").Range("E" & P).Value = CDate(Me.TextBox2.Value)
Sheets("planning").Range("D" & P).Value = ComboBox4.Value
Sheets("planning").Range("F" & P).Value = ComboBox5.Value

Unload Me 'Vide et ferme le UserForm
ActiveSheet.Protect ("wt01oks3")




End Sub

Private Sub ComboBox2_Change()
With Sheets("suivi appro")
TextBox1 = .Cells(ComboBox2.ListIndex + 4, 17)
End With
If TextBox1 <> "" Then TextBox2 = DTPicker1 + TextBox1 - 1

End Sub
Private Sub DTPicker1_Change()
If TextBox1 <> "" Then TextBox2 = DTPicker1 + TextBox1 - 1

End Sub

Private Sub UserForm1_Initialize()
Dim c As Range
With Sheets("suivi appro")
Set c = .Range("D4😀" & .Range("D65000").End(xlUp).Row)
End With
ComboBox2.List = c.Value
DTPicker1 = VBA.Date

End Sub
Private Sub ComboBox4_Change()

ComboBox4.Value = Format(ComboBox4.Value, "hh:mm")

End Sub
Private Sub ComboBox5_Change()

ComboBox5.Value = Format(ComboBox5.Value, "hh:mm")

End Sub

Private Sub CancelButton_Click()
Select Case MsgBox("Voulez vous quitter ?", vbYesNo Or vbInformation)
Case vbYes
Unload Me
Case vbNo
End Select
End Sub
 
Re : format 12:00 = 00:00

.rar passe pas voici en zip
est il possible que la date du DTPicker ce mette a jour automatiquement car elle reste figer sur la meme date quand j'ouvre mon userform
 

Pièces jointes

Dernière édition:
Re : format 12:00 = 00:00

Re,

comme dit dans le post 2, fonctionne ainsi, enfin chez moi...
Code:
Private Sub ComboBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox4.Value = Format(ComboBox4.Value, "hh:mm")
End Sub

Ou alors quelque chose m'a échappé...
 
- 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
9
Affichages
256
Réponses
9
Affichages
854
Réponses
7
Affichages
707
Réponses
12
Affichages
228
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…