Solved

VBA for Excel, How do I Limit Choices in the ComboBox,

Posted on 2011-09-11
4
346 Views
Last Modified: 2012-06-27
I am trying to limit my UserForm1.comboBox1  to predefined choices and not letting the user to write inside it without actually greying it out.....

Any idea as to how to do this either within the VBA Properties window or a Macro ?

Thanks in advance....
0
Comment
Question by:New_Alex
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
AgeOfEmpires earned 500 total points
ID: 36519286
If you set it's Style property to frmStyleDropDownList, the user can only select the items you've predefined.  The default Style property for the combobox is frmStyleDropDownCombo, which let's the user choose from your predefined choices, or enter a value of their own.
0
 
LVL 33

Expert Comment

by:Norie
ID: 36519299
Why not check if what they've entered is one of the choices?

Assuming the choices are in the comboboxes dropdown you can do that by checking the ListIndex.

If they've entered something that's not on the list it will be -1 and if it is on the list it will return the index of the item in the list.
0
 
LVL 1

Author Closing Comment

by:New_Alex
ID: 36536207
Thank you SIR !
0
 
LVL 4

Expert Comment

by:AgeOfEmpires
ID: 36536300
Glad I could assist.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Outlook Free & Paid Tools
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question