XL 2016 Somme des heures dans textbox

Stefbarbu

XLDnaute Nouveau
Bonjour à tous,
je suis un petit nouveau sur votre site et débutant en VBA. J'aurais besoin d'un coup de pouce SVP.
J'ai fait un formulaire avec userform et j'ai plusieurs textbox, dont certains pour inscrire des heures.
Lorsque la personne clic sur valider, je voudrais avoir la somme des heures inscrit dans les textbox.
Pour le reste, tout fonctionne bien, mais pour la somme des heures, ça bloque !

Merci pour votre aide !

Private Sub Bt_Valider_Click()
Dim DerLig As Integer
Dim LigneRef As Integer
Dim Feuille As String

For i = 1 To 25
If ComboBox1.Value = ActiveWorkbook.Worksheets("RÉF").Cells(i, 1).Value Then
LigneRef = i
i = 100
End If
Next i

If ComboBox1.Value = "" Then
MsgBox "Vous devez sélectionner un type de contrat !", vbExclamation, _
"ATTENTION ... Information manquante !"
ComboBox1.SetFocus
Exit Sub
End If
If ComboBox2.Value = "" Then
MsgBox "Vous devez indiquer le nom de l'agent(e) !", vbExclamation, _
"ATTENTION ... Information manquante !"
ComboBox2.SetFocus
Exit Sub
End If

Feuille = Format(DTPicker1.Value, "mmmm")
Feuille = Format(DTPicker2.Value, "mmmm")
Sheets(Feuille).Select
DerLig = Range("b65536").End(xlUp).Row + 1

Cells(DerLig, 2).Value = DTPicker1.Value 'date de saisie
Cells(DerLig, 3).Value = DTPicker2.Value 'date du contrat
Cells(DerLig, 4).Value = CDbl(Label44) 'no de contrat
Cells(DerLig, 5).Value = ComboBox1.Value 'type contrat
Cells(DerLig, 6).Value = ActiveWorkbook.Worksheets("RÉF").Cells(LigneRef, 2).Value 'prix bus rég avec tx
Cells(DerLig, 7).Value = ActiveWorkbook.Worksheets("RÉF").Cells(LigneRef, 3).Value 'prix bus arti avec tx
Cells(DerLig, 8).Value = ActiveWorkbook.Worksheets("RÉF").Cells(LigneRef, 4).Value 'prix co avec tx

Cells(DerLig, 9).Value = Val(TextBox1.Value) + Val(TextBox2.Value) + Val(TextBox3.Value) + Val(TextBox4.Value) + Val(TextBox5.Value) + Val(TextBox6.Value) _
+ Val(TextBox7.Value) + Val(TextBox8.Value) 'nbre bus reg

Cells(DerLig, 10) = Format(CDate(TextBox9), "hh:mm;@") + Format(CDate(TextBox10), "hh:mm;@") + Format(CDate(TextBox11), "hh:mm;@") + Format(CDate(TextBox12), "hh:mm;@") _
+ Format(CDate(TextBox13), "hh:mm;@") + Format(CDate(TextBox14), "hh:mm;@") + Format(CDate(TextBox15), "hh:mm;@") + Format(CDate(TextBox16), "hh:mm;@") 'heure bus reg


Cells(DerLig, 11).Value = Val(TextBox17.Value) + Val(TextBox18.Value) + Val(TextBox19.Value) + Val(TextBox20.Value) + Val(TextBox21.Value) + Val(TextBox22.Value) _
+ Val(TextBox23.Value) + Val(TextBox24.Value) 'nbre bus arti

Cells(DerLig, 12).Value = (TextBox25.Value) + (TextBox26.Value) + (TextBox27.Value) + (TextBox28.Value) _
+ (TextBox29.Value) + (TextBox30.Value) + (TextBox31.Value) + (TextBox32.Value) 'heure bus arti

Cells(DerLig, 13).Value = TextBox33.Value 'co
Cells(DerLig, 14).Value = TextBox34.Value 'heure co
Cells(DerLig, 18).Value = ComboBox2.Value 'agente
 

Discussions similaires

Statistiques des forums

Discussions
312 047
Messages
2 084 858
Membres
102 688
dernier inscrit
Biquet78