P
Patrick Simonds
The code below is designed to change a number input, such as 1425 to 14:25.
Is there anything I can do prevent the code from running if the number is
already properly inputted?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim e
ActiveSheet.Unprotect
On Error GoTo ErrorHandler
If Not Application.Intersect(Target, Range("E3:E8000")) Is Nothing Then
If ActiveCell < "" Then GoTo ErrorHandler
e = Left(Format(Target.Value, "0000"), 4)
Application.EnableEvents = False
Target.Formula = Left(e, 2) & ":" & Right(e, 2)
End If
Application.EnableEvents = True
If ActiveCell = ":" Then GoTo ClearCell
Exit Sub
ClearCell:
Selection.ClearContents
Exit Sub
ErrorHandler:
Exit Sub:
End Sub
Is there anything I can do prevent the code from running if the number is
already properly inputted?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim e
ActiveSheet.Unprotect
On Error GoTo ErrorHandler
If Not Application.Intersect(Target, Range("E3:E8000")) Is Nothing Then
If ActiveCell < "" Then GoTo ErrorHandler
e = Left(Format(Target.Value, "0000"), 4)
Application.EnableEvents = False
Target.Formula = Left(e, 2) & ":" & Right(e, 2)
End If
Application.EnableEvents = True
If ActiveCell = ":" Then GoTo ClearCell
Exit Sub
ClearCell:
Selection.ClearContents
Exit Sub
ErrorHandler:
Exit Sub:
End Sub