Assuming column A, format the column as text, then use
this code:
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Column <> 1 Then Exit Sub 'col A=1,B=2,etc.
If .Count > 1 Then Exit Sub
Application.EnableEvents = False
If IsNumeric(.Value) Then
If Len(.Value) <> 6 Then
MsgBox "Please enter 6 numbers."
GoTo ExitThisSub
ElseIf Left(.Value, 2) > 24 Or _
Mid(.Value, 3, 2) > 59 Or _
Right(.Value, 2) > 59 Then
MsgBox "The maximum time allowed " & _
"is 23:59:59."
GoTo ExitThisSub
End If
Else
MsgBox "Invalid entry."
GoTo ExitThisSub
End If
.NumberFormat = "General"
.Value = TimeSerial(Left(.Value, 2), _
Mid(.Value, 3, 2), Right(.Value, 2))
.NumberFormat = "[hh]:mm:ss"
Application.EnableEvents = True
Exit Sub
ExitThisSub:
.ClearContents
.Select
Application.EnableEvents = True
Exit Sub
End With
End Sub
---
To use the code, right-click on the worksheet tab, go to
View Code, and paste in the code above. Press ALT+Q to
close.
HTH
Jason
Atlanta, GA