Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim timeV As String, info As String
If Target.Address(0, 0) <> "A3" Then
On Error Resume Next
timeV = Format(Range("A3").Value, "hh:mm")
On Error GoTo 0
If Len(timeV) <> 5 Then
With Range("A3")
info = MsgBox(" Invalid time value! Do you want to input again?" & vbLf & vbLf _
& "Yes (Input again)" & vbLf & vbLf & "No (leave it as current time", vbYesNo)
Select Case info
Case vbYes
.Select
.ClearContents
Case vbNo
.Value = TimeValue(Now)
End Select
End With
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim timeV As String
Dim answer As String
Dim kol_A_rng As Range
Set kol_A_rng = Range("A3:A3")
If Not Application.Intersect(Target, kol_A_rng) Is Nothing Then
Do
timeV = Format(Target.Value, "hh:mm")
If IsDate(timeV) Then
timeV = Format(timeV, "hh:mm")
'MsgBox ("ok")
ElseIf timeV = "" Then
Target.Select
answer = MsgBox("INVALID ENTRY. TRY AGAIN ?", vbYesNo)
Application.Undo
Exit Sub
Else
Target.Select
answer = MsgBox("INVALID ENTRY. TRY AGAIN ?", vbYesNo)
Application.Undo
Exit Sub
End If
Loop While Not (IsDate(timeV))
Else
End If
End Sub