Здравствуйте.
[vba]Код
Private Sub Worksheet_Change(ByVal Target As Range)
Dim vVal, oRE As Object
On Local Error Resume Next
If Intersect(Target, Range("D9")) Is Nothing Then Exit Sub
Application.EnableEvents = 0
With Target
Set re = CreateObject("vbscript.regexp")
re.Pattern = "^([0-1][0-9]|2[0-3])[0-5][0-9]$"
vVal = Format(.Value, "0000")
If re.test(vVal) Then
.Value = Application.Replace(vVal, 3, 0, ":")
.NumberFormat = "h:mm"
Else
MsgBox "Введенные данные не соответствуют времени в формате ччмм"
Application.Undo
End If
End With
Application.EnableEvents = True
Set re = Nothing
End Sub
[/vba]