I have code that moves a time entered value to a field using a specific time format. However, when entering the time, if it isn't entered in the correct format, the user gets the Runtime 13 error and then cannot do anything other than close the userform, stop the code from running, and try again. I can format a message to return an error telling the user to correct the entry but what code do I use to put the user back into the field and allow them to make a correction? I am putting the code for this userform textbox here for reference:
Private Sub txtDepartTime_AfterUpdate()
'When time is entered, time transfers immediately to spreadsheet datafield.
Dim TargetRow As Integer
TargetRow = Sheets("Codes").Range("D43").Value + 1
With Sheets("Travel Expense Voucher").Range("Data_Start").Offset(TargetRow, 25)
.Value = TimeValue(txtDepartTime)
.NumberFormat = "hh:mm" 'departure time
End With
End Sub