Da ich viele Eingaben in dieser Form machen muss würde mir diese Formatierung die Eingabe sehr erleichtern und verschnellern.
Gruss
M@x
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sTxt As String
If Target.Column < 5 Or Target.Column > 21 Then Exit Sub
If IsEmpty(Target) Or Selection.Cells.Count > 1 Then Exit Sub
sTxt = CStr(Target.Value)
Select Case Len(sTxt)
Case 3: sTxt = "0" & sTxt & "00"
Case 4: sTxt = sTxt & "00"
Case 5: sTxt = "0" & sTxt
End Select
sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2)
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Target.Value = TimeValue(sTxt)
Application.EnableEvents = True
Exit Sub
ERRORHANDLER:
ActiveCell.ClearContents
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sTxt As String
If Target.Column < 5 Or Target.Column > 21 Then Exit Sub
If IsEmpty(Target) Or Selection.Cells.Count > 1 Then Exit Sub
sTxt = CStr(Target.Value)
Select Case Len(sTxt)
Case 3: sTxt = "0" & sTxt & "00"
Case 4: sTxt = sTxt & "00"
Case 5: sTxt = "0" & sTxt
End Select
sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2)
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Target.Value = TimeValue(sTxt)
Application.EnableEvents = True
Exit Sub
ERRORHANDLER:
ActiveCell.ClearContents
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sTxt As String
If Target.Column < 5 Or Target.Column > 21 Then Exit Sub
If IsEmpty(Target) Or Selection.Cells.Count > 1 Then Exit Sub
sTxt = CStr(Target.Value)
Select Case Len(sTxt)
Case 3: sTxt = "0" & sTxt & "00"
Case 4: sTxt = sTxt & "00"
Case 5: sTxt = "0" & sTxt
End Select
sTxt = Left(sTxt, 2) & ":" & Mid(sTxt, 3, 2) & ":" & Right(sTxt, 2)
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
Target.Value = TimeValue(sTxt)
Application.EnableEvents = True
Exit Sub
ERRORHANDLER:
ActiveCell.ClearContents
Application.EnableEvents = True
End Sub
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen