Userform is adding info for up to 20 people (Potential for 8 adults labeled Adult1, adult2..... and 12 children labeled Child1, child 2....)
for each of the people, I have to run the same validations.
1. If a first name is entered there MUST be a last name entered
2. If a last name is entered there MUST be a first name entered
3. If a first name and last name is entered a DOB must be entered
4. If a first name and last name is entered then a validation yes/no box is to be checked.
I am basically looking to try and combine the macro code behind the scenes in an effort to optimize.
Example of DOB Validation code is
is there any way to do this?
Private Sub TextBox14_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If DisableEvents Then Exit Sub
If Me.TextBox12.Value <> "" Or Me.TextBox13.Value <> "" Then
If Not TextBox14.Value Like "##[/]##[/]####" Then
MsgBox "Adult 1 DOB Must Be in the Format of mm/dd/yyyy"
Cancel = True
TextBox14.Value = ""
Else
If DateValue(TextBox14.Value) > DateValue(Now) Then
MsgBox "Adult 1 DOB Must be in the Past"
Cancel = True
TextBox14.Value = ""
Else
TextBox14.SetFocus
End If
End If
End If
End Sub
Bookmarks