Archive of Mr Excel Message Board


Back to Controls in Excel archive index
Back to archive home

Combobox... need an event similar to 'Not in List'

Posted by Kevin on August 02, 2001 6:35 AM
I need to have a 'Not in List' event the gets tricked after the user has entered a value into a combobox. I have the behaviour MatchRequired property set to True but when a user enters a value that is not in the list and press the Tab key, Excel returns 'Invalid property Value', not very user friendly.

Thanks in advance
regards
KM

KM


Re: Combobox... need an event similar to 'Not in List'

Posted by Cory on August 02, 2001 8:35 AM
Have you tried using an error trap that'll skip the "invalid poroperty" error? If not, try this:

Private Sub YourSub()
On Error GoTo errorname
(your code here...)
Exit Sub
errorname: msgbox ("Sorry, that's not valid. Try again...", vbokonly, "Invalid Choice")
Exit Sub
End Sub

You can change "errorname" to whatever you want to call the code that runs in event of an error. The keys here are the Exit Subs. If you don't have one BEFORE errorname and at the END of the error code, the error code will run whether there's an error or not...

Cory


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.