D3allamerican07
Board Regular
- Joined
- Jul 22, 2015
- Messages
- 101
Hi, I am using a textbox along with a combobox and command button. I need it to check for 4 things,
1. If there is nothing in the Textbox
2. If the Textbox value is in a range on a separate sheet
3. If the Textbox value is not in a range on a separate sheet
4. Or it should pull up the sheet which is the Textbox value
Here is my code so far...
Private Sub SearchFor_Click()
If TextBox.Value = "" Then
MsgBox "Please enter value"
ElseIf TextBox.Value <> Worksheets("Sheet2").Range("A1:A50").Value Then
MsgBox "No it does not exist"
ElseIf TextBox.Value = Worksheets("Sheet2").Range("A1:A50").Value Then
MsgBox "Yes it exists"
Else
Worksheets(ActiveSheet.TextBox.Value).Activate
End If
End Sub
1. If there is nothing in the Textbox
2. If the Textbox value is in a range on a separate sheet
3. If the Textbox value is not in a range on a separate sheet
4. Or it should pull up the sheet which is the Textbox value
Here is my code so far...
Private Sub SearchFor_Click()
If TextBox.Value = "" Then
MsgBox "Please enter value"
ElseIf TextBox.Value <> Worksheets("Sheet2").Range("A1:A50").Value Then
MsgBox "No it does not exist"
ElseIf TextBox.Value = Worksheets("Sheet2").Range("A1:A50").Value Then
MsgBox "Yes it exists"
Else
Worksheets(ActiveSheet.TextBox.Value).Activate
End If
End Sub