funkykayli
Board Regular
- Joined
- Apr 25, 2007
- Messages
- 183
I have a user form with an OK button on it. I have the following code attached to the OK button:
Private Sub cmdOK_Click()
If Me.cboTreat.Value = "" Then
MsgBox "Please Choose a Treatment Type.", vbExclamation, "Welcome"
Me.cboTreat.SetFocus
End If
End Sub
The code works fine. If someone clicks on the OK button without choosing an item from the combo box the message box appears. What I want to do is if the user chooses an item from the combo box and then clicks ok I want the focus to go to the workbook sheet Pivot. I tried entering an else statement and putting in sheet("Pivot").activate but this does not seem to work. Am I on the right track entering an esle statement?
Private Sub cmdOK_Click()
If Me.cboTreat.Value = "" Then
MsgBox "Please Choose a Treatment Type.", vbExclamation, "Welcome"
Me.cboTreat.SetFocus
End If
End Sub
The code works fine. If someone clicks on the OK button without choosing an item from the combo box the message box appears. What I want to do is if the user chooses an item from the combo box and then clicks ok I want the focus to go to the workbook sheet Pivot. I tried entering an else statement and putting in sheet("Pivot").activate but this does not seem to work. Am I on the right track entering an esle statement?