Format HH:MM supérieur à 24h

Ian83

XLDnaute Nouveau
Bonjour à tous et à toutes.
J'ai besoin un peu d'aide car cela fait plusieurs jours que je cherche et que je ne trouve pas la solution.
Dans le textbox ou label, je souhaiterai saisir et récupérer la durée en format "HH:MM" supérieur à 24:00.
Je vous transmets le fichier.
En attente de votre aide, passez une bonne journée.

Voici le code:

Private Sub Ajouter_Click()
'double click bonton ajouter
If ComboBox1.Value = "" Then
MsgBox "Veuillez renseigner le champs 'NOM et Prénom'"
Else
Dim ligne As Integer
If MsgBox("Confirmez-vous l'ajout des données ?", vbYesNo, "Confirmation") = vbYes Then
Sheets(1).Visible = True
Sheets(1).Unprotect
Worksheets(1).Select
ligne = Sheets(1).Range("A104857").End(xlUp).Row + 1
Cells(ligne, 1) = TextBox2.Value
Cells(ligne, 2) = ComboBox1.Value
Cells(ligne, 3) = TextBox1.Value
Cells(ligne, 4) = ComboBox2.Value
Cells(ligne, 5) = ComboBox3.Value
Cells(ligne, 6) = ComboBox4.Value
Cells(ligne, 7) = TextBox3.Value
Sheets(1).Protect
Sheets(1).Visible = False
Unload UserForm1
UserForm1.Show
Else
End If
End If

End Sub


Private Sub Modifier_Click()
'bonton Modifier
Dim modif As Integer
If Not ComboBox1.Value = "" Then
Sheets(1).Visible = True
Sheets(1).Unprotect
Sheets(1).Select
modif = ComboBox1.ListIndex + 2
Cells(modif, 1) = TextBox2.Value
Cells(modif, 2) = ComboBox1.Value
Cells(modif, 3) = TextBox1.Value
Cells(modif, 4) = ComboBox2.Value
Cells(modif, 5) = ComboBox3.Value
Cells(modif, 6) = ComboBox4.Value
Cells(modif, 7) = Label8.Caption
Sheets(1).Protect
Sheets(1).Visible = False
MsgBox ("Modification effectuée")
Else
MsgBox ("Veuillez sélectionner le NOM et Prénom de l'agent à modifier")
Exit Sub
End If

Unload UserForm1
UserForm1.Show 0


End Sub

Private Sub Rechercher_Click()
'double click sur le bouton Rechercher
If Not ComboBox1.Value = "" Then
Sheets(1).Visible = True
Sheets(1).Select
Dim no_ligne As Integer
no_ligne = ComboBox1.ListIndex + 2
TextBox2.Value = Cells(no_ligne, 1).Value
ComboBox1.Value = Cells(no_ligne, 2).Value
TextBox1.Value = Cells(no_ligne, 3).Value
ComboBox2.Value = Cells(no_ligne, 4).Value
ComboBox3.Value = Cells(no_ligne, 5).Value
ComboBox4.Value = Cells(no_ligne, 6).Value
Label8.Caption = Format(Cells(no_ligne, 7).Value, "hh:mm")
Sheets(1).Visible = False
Else
End If

End Sub

Private Sub Supprimer_Click()
If ComboBox1.Value = "" Then
Sheets(1).Visible = True
MsgBox ("Veuillez sélectionner le Nom et Prénom de l'agent à supprimer")
Else
If MsgBox("Confirmez-vous la suppression de l'agent ?", vbYesNo, "Confirmation") = vbYes Then
Sheets(1).Visible = True
Sheets(1).Unprotect
Worksheets(1).Select
Rows([B2:C1048576].Find(ComboBox1.Value).Row).EntireRow.Delete
Sheets(1).Protect
Sheets(1).Visible = False
End If
End If

Unload UserForm1
UserForm1.Show
End Sub

Private Sub TextBox3_AfterUpdate()
If TextBox3.Value = "" Then TextBox3.Tag = 0 Else TextBox3.Tag = TextBox3.Value
total
End Sub

Private Sub total()
Label8.Caption = Format(CDate(1 - CDate(TextBox3.Tag)), "hh:mm")
End Sub
 

soan

XLDnaute Barbatruc
Inactif
Bonjour @Ian83,

bonne année 2021, et bienvenue sur le site XLD ! 🥳

juste une piste : pour un nombre d'heures supérieur à 24,
utilise le format :
[h]:mm (avec les crochets) ; donc :

* dans ta sub Rechercher_Click() :


Label8.Caption = Format(Cells(no_ligne, 7).Value, "[h]:mm")

* dans ta sub total() :

Label8.Caption = Format(CDate(1 - CDate(TextBox3.Tag)), "[h]:mm")

je n'ai rien d'autre à proposer. :confused:



d'autre part, ici, tu es sur "Ressources et articles / Trucs et astuces" ;
tu auras plus de chances d'obtenir des réponses si tu postes ta
demande sur "Questions / Forum Excel" ; bonne chance ! 🍀


soan
 

Statistiques des forums

Discussions
312 171
Messages
2 085 931
Membres
103 049
dernier inscrit
plt