PDA

View Full Version : Solved: Userform - ComboBox list problem



JarryS88
10-14-2010, 06:41 PM
Hi,

I have a userform which opens on start.

i have drop down combobox's within this userform however for a user to display the list they need to type a character on the keyboard before it allows them to drop down or click the down arrow.

I want to make it so the user can click the down arrow on the combobox and it will show the list, without having to type a character first.

i've searched all over the internet for an answer or similar problem and havent seemed to find anything.

please help.

garydp
10-14-2010, 07:08 PM
when you add the items to the combo box do you double click the combo box and then put them under

Private Sub ComboBox1_Change()
Combobox1.Clear
Combobox1.AddItem "Item1"
Combobox1.AddItem "Item2"
End Sub

if so try

Private Sub ComboBox1_DropButtonClick()
Combobox1.Clear
Combobox1.AddItem "Item1"
Combobox1.AddItem "Item2"
End sub

im not that great at vba so this may be completely wrong but it works for me.

lehgzil
10-14-2010, 07:42 PM
hi jarry,

if you want to have the value of you're combobox on the start of the userform and that you want to have you're user just click the down arrow button to view the list well, here's what i do

put the line of code on the userform_initialize event like this

Private Sub UserForm_Initialize()
With Me.ComboBox1
.additem "a"
.additem "b"
End With
With Me.ComboBox2
.additem "1"
.additem "2"
end with
End sub

this will also prevent duplicates whenever youre user changed comboboxes and go back to previous one.

searched also for my previous threads, some of it was all about comboboxes, credits to those who help me with that.

hope this helps.
thanks

JarryS88
10-14-2010, 08:08 PM
i have my userforms set up as below

userform1.controls("combobox1").list=array("first item", "second item", etc etc)
userform1.controls("combobox1").dropdown.

JarryS88
10-14-2010, 08:16 PM
hi thanks lehgzil
i had to put it in a
Private Sub UserForm_Initialize()
End Sub


thanks heaps :)

lehgzil
10-14-2010, 08:17 PM
try this?

Private Sub UserForm_Initialize()
UserForm1.Controls("combobox1").List = Array("first item", "second item")
UserForm1.Controls("combobox1").DropDown
End Sub copy paste this to your userform module..
...............................................

hi thanks lehgzil
i had to put it in a



VBA:

Private Sub UserForm_Initialize() End Sub

VBA tags courtesy of www.thecodenet.com (http://www.thecodenet.com/)


thanks heaps :)

ok thanks for trying the code...mark this thread as solved if this answers youre question... thanks again, credits to those who also helped me...

JarryS88
10-14-2010, 09:04 PM
sorry, new to this forum.
how do i mark as solved?

lehgzil
10-14-2010, 10:07 PM
look at the top part of this thread, your first post, at top of that, there will be thread tools right before search this thread. click that and there it will be, mark as solved.. ^_^