I am using the following code to format the entry of time into a text field:
I have 30 more text fields (txtTime1,2,3, etc) that need the same formatting to be done after the field is updated. Can this be done with a loop? Create a module that can be applied to each field as it is adjusted? How would one go about doing this other than copy/pasting and adjusting the code for each field?
HTML:
Private Sub txtTime1_AfterUpdate()
With txtTime1
If IsDate(.Value) Then
.Value = Format(.Value, "HH:MM AM/PM")
Else
MsgBox "Input time as HH:MM"
.Value = ""
Cancel = True
End If
End With
End Sub