Hi Everyone
I am using Excel from the Microsoft Office (2003) package.
I have created a userform with combo boxes allowing the user to make certain selections.
Lets say that ComboBox1 has the added items: "0", "1", "2" when the userform is initialized. I require the user to select one of these values (i've tried using the 'matchrequired' property but i'm not happy with the way it handles the error of incorrectly entering data).
Lets say that the user inputs "5" instead of one of the 3 valid options. I have got this code to try and deal with the error:
My problem occurs in between the stars ('*****). Ideally i would like to be able to highlight the existing incorrect value in ComboBox1. 2nd Prize would be to SetFocus on ComboBox1. At the moment it highlights the default value in ComboBox2.
Any help/suggestions would be greatly appreciated.
Thanks
Steve
I am using Excel from the Microsoft Office (2003) package.
I have created a userform with combo boxes allowing the user to make certain selections.
Lets say that ComboBox1 has the added items: "0", "1", "2" when the userform is initialized. I require the user to select one of these values (i've tried using the 'matchrequired' property but i'm not happy with the way it handles the error of incorrectly entering data).
Lets say that the user inputs "5" instead of one of the 3 valid options. I have got this code to try and deal with the error:
Code:
Private Sub ComboBox1_AfterUpdate()
x = Userform.ComboBox1.Value
If (x = "0") Or (x = "1") Or (x = "2") Then
'do nothing
Else
'*****
[b]
Userform.ComboBox1.SetFocus
[/b]
'*****
MsgBox "An invalid entry has been made. Please make sure your selection features in the drop-down menu."
Exit Sub
End If
End Sub
My problem occurs in between the stars ('*****). Ideally i would like to be able to highlight the existing incorrect value in ComboBox1. 2nd Prize would be to SetFocus on ComboBox1. At the moment it highlights the default value in ComboBox2.
Any help/suggestions would be greatly appreciated.
Thanks
Steve