Wie kann ich die Zeit aus einer Zelle korrekt in eine Textbox einlesen (z.B. 47:08 soll auch so bleiben)? Und wie kann ich solche Zeiten aus fünf Textboxen in einer weiteren Textbox zusammenzählen? Danke wieder einmal für die Hilfe!
Gruss Rene
Private Sub UserForm_Initialize()
TextBox1 = Range("A1").Text
TextBox2 = Range("A2").Text
TextBox3 = Range("A3").Text
TextBox4 = WorksheetFunction.Text(Range("A1") + Range("A2") + Range("A3"), "[h]:mm")
End Sub
Private Sub CommandButton31_Click()
On Error Resume Next
Dim i1Zeit As Integer
Dim i2Zeit As Integer
Dim i3Zeit As Integer
Dim i4Zeit As Integer
Dim i5Zeit As Integer
Dim i1Posit As Integer
Dim i2Posit As Integer
Dim i3Posit As Integer
Dim i4Posit As Integer
Dim i5Posit As Integer
Dim i As Integer
i1Posit = InStr(TextBox1.Value, ":")
i2Posit = InStr(TextBox2.Value, ":")
i3Posit = InStr(TextBox3.Value, ":")
i4Posit = InStr(TextBox4.Value, ":")
i5Posit = InStr(TextBox5.Value, ":")
i1Zeit = CInt(Left(TextBox1.Value, i1Posit - 1) * 60) + _
CInt(Right(TextBox1.Value, Len(TextBox1.Value) - i1Posit))
i2Zeit = CInt(Left(TextBox2.Value, i2Posit - 1) * 60) + _
CInt(Right(TextBox2.Value, Len(TextBox2.Value) - i2Posit))
i3Zeit = CInt(Left(TextBox3.Value, i3Posit - 1) * 60) + _
CInt(Right(TextBox3.Value, Len(TextBox3.Value) - i3Posit))
i4Zeit = CInt(Left(TextBox4.Value, i4Posit - 1) * 60) + _
CInt(Right(TextBox4.Value, Len(TextBox4.Value) - i4Posit))
i5Zeit = CInt(Left(TextBox5.Value, i5Posit - 1) * 60) + _
CInt(Right(TextBox5.Value, Len(TextBox5.Value) - i5Posit))
TextBox6.Value = Format(Int((i1Zeit + i2Zeit + i3Zeit + i4Zeit + i5Zeit) / 60) + ((i1Zeit + i2Zeit + i3Zeit + i4Zeit + i5Zeit) / 60 - _
Int((i1Zeit + i2Zeit + i3Zeit + i4Zeit + i5Zeit) / 60)) * 60 / 100, "#0.00")
TextBox6.Value = Replace(TextBox6.Value, ",", ":")
End Sub