Good day!
I have a Userform that displays a combobox and also a textbox. I want to display a MsgBox if the user types in a name in the Textbox that doesn't already exist in the table. Right now it technically works as it displays a "Runtime Error 1004 - Unable to get the Match property of the WorksheetFunction class." But rather than showing this Excel VBA error message, I'd rather it just show a MsgBox that a user can just click OK and return to the userform.
Table Worksheet - Employee List
Table - Employees
I have a Userform that displays a combobox and also a textbox. I want to display a MsgBox if the user types in a name in the Textbox that doesn't already exist in the table. Right now it technically works as it displays a "Runtime Error 1004 - Unable to get the Match property of the WorksheetFunction class." But rather than showing this Excel VBA error message, I'd rather it just show a MsgBox that a user can just click OK and return to the userform.
Table Worksheet - Employee List
Table - Employees
VBA Code:
Private Sub CommandButton1_Click()
'Check to see if Valid search entries
If ComboBox1.Value <> "" And Trim(TextBox1.Text) <> "" Then
MsgBox "Please use the drop down menu OR the Last Name text box. You cannot search using both."
Exit Sub
ElseIf ComboBox1.Value = "" And Trim(TextBox1.Text) = "" Then
MsgBox "Invalid parameters."
Exit Sub
Else
End If
'Write data to cell for lookup later
If ComboBox1.Value <> "" Then
Range("FullNameLookUp").Value = ComboBox1.Value
Else
Range("LastNameLookUp").Value = TextBox1.Value
End If
Unload Me
With EmployeeLookup
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
End With
End Sub