|
-
Jan 29th, 2004, 04:40 AM
#1
Thread Starter
New Member
Combo Box Problem
I am new to VB and VBA and have a problm getting items into a Combo Box.
Could someone please tell me the code to add two items into a combox box so that this becomes visible and functional on my excel sheet, as I can't get it to work?
Many thanks in advance.
-
Feb 9th, 2004, 06:14 AM
#2
Junior Member
You have two ways to do this if your using excel, the choice of which is entirely up to you.
Forms Object
If you just need a simple drop down menu you can use the combo box found on the forms menu. Simply add the object to your worksheet and then right click on it, select Format Control, select the control Tab. You will three fields and a check box, the first field is the Input Range, all you have to do is select the range of data you would like to see in the actual combo box (ie highlight it). The next field is the Cell Link, this is where the index of the selected item will be stored (so if you click on item 6, a 6 will be stored here), finallyt you have a field asking how many drop down lines you would like to be able to see at once (just alter the value to suit your needs). Below that you will see a checkbox, if its ticked your combo box will appear 3D if not then it will appear 2D (again just alter to suit your needs).
VBA Object
The VBA combo box can be added either to the worksheet or to a form, either way the method of dealing with it remains the same.
To add an item to the list box : ComboBox1.AddItem "Put item description here"
Also remember that when you add a vba object to a worksheet you start in Design mode - so your objects won't be selectable and any code attached won't run. Exit design mode in order to see your objects working..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|