Hello,
I am wondering if there is a way to apply a text box validation to all the text boxes on my userform. I have a working validation and I can apply it individually, but if I want to add lots more text boxes this wouldn't be very practical.
So is there a way to cycle through all the text boxes and apply this validation?
Regards,
Tripp
I am wondering if there is a way to apply a text box validation to all the text boxes on my userform. I have a working validation and I can apply it individually, but if I want to add lots more text boxes this wouldn't be very practical.
So is there a way to cycle through all the text boxes and apply this validation?
Regards,
Tripp
Code:
Private Sub TextBox_Exit(ByVal cancel As MSForms.ReturnBoolean)
If IsNumeric(NameTextBox.Text) Or NameTextBox.Value = "" Then
TB1.BackColor = &HFF&
MsgBox "Wrong"
cancel = True
Else
TB1.BackColor = &H80000005
End If
If IsNumeric(DateTextBox.Text) Or DateTextBox.Value = "" Then
TB1.BackColor = &HFF&
MsgBox "Wrong"
cancel = True
Else
TB1.BackColor = &H80000005
End If
If IsNumeric(SiteTextBox.Text) Or SiteTextBox.Value = "" Then
TB1.BackColor = &HFF&
MsgBox "Wrong"
cancel = True
Else
TB1.BackColor = &H80000005
End If
End Sub