Solved

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

Posted on 2011-09-11
4
339 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now