I'm using this script I found on the Microsoft forum to allow me to enter military time without having to enter the ":" every time. It works fine, until I add a blank row or delete a row. Then I get an error. How can I get this code to ignore deletions and additions in the range that don't meet the expected format?
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
Dim xHour As String
Dim xMinute As String
Dim xWord As String
Application.EnableEvents = False
xWord = Format(Target.Value, "0000")
xHour = Left(xWord, 2)
xMinute = Right(xWord, 2)
On Error Resume Next
Target.Value = TimeValue(xHour & ":"& xMinute)
On Error Resume Next
Application.EnableEvents = True
End Sub