| TimeValue, IsNumeric, IsEmpty, CStr |
| |
| |
| Sub Worksheet_Change(ByVal T As Range) | |
| Dim sTxt | |
| If T.Column = 3 Then | Hier wird nur die gewünschte Spalte eingetragen. |
| If IsEmpty(T) Or Selection.Cells.Count > 1 Then Exit Sub | |
| If Not IsNumeric(T.Value) Then Exit Sub | |
| sTxt = CStr(T.Value) | |
| Select Case Len(sTxt) | |
| Case 1: sTxt = "00000" & sTxt | |
| Case 2: sTxt = "0000" & sTxt | |
| Case 3: sTxt = "000" & sTxt | |
| Case 4: sTxt = "00" & sTxt | |
| Case 5: sTxt = "0" & sTxt | |
| End Select | |
| On Error GoTo errr | |
| Application.EnableEvents = False | |
| If sTxt > 235959 Then | Wenn Zeit größer als ein Tag gibt’s Probleme. |
| sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) | |
| T.Value = sTxt | |
| Else | |
| sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2) | |
| T.Value = TimeValue(sTxt) | |
| End If | |
| Else | |
| Exit Sub | |
| End If | |
| Application.EnableEvents = True | |
| Exit Sub | |
| errr: | |
| T.Value = "Fehler" | Bei Fehler Zelle selektieren und Meldung ausgeben. |
| T.Select | |
| Application.EnableEvents = True | |
| End Sub | |
| |