I have the userform with a textbox on it. I want to validate for the presence of several characters and phrases (placed them in an array). It is generating an error "Run-time error 402. Must close or hide topmost modal form first". I need to hide userform2 when I display back userform1. Any suggestions how to change the code?
Private Sub CommandButton1_Click() Dim ArrayCh As Variant ArrayCh = Array("etc", "<", "%", ">", ";", "[", "]") For i = LBound(ArrayCh) To UBound(ArrayCh) If InStr(1, UserForm2.TextBox1.Text, ArrayCh(i), vbTextCompare) > 0 Then MsgBox "The word/phrase/character " & ArrayCh(i) & " is not allowed in the title" Else UserForm1.txtTI1.Text = UserForm2.TextBox1.Text UserForm2.Hide End If Next i End Sub