Consulting

Results 1 to 8 of 8

Thread: Solved: Userform - ComboBox list problem

  1. #1
    VBAX Regular
    Joined
    Oct 2010
    Posts
    11
    Location

    Solved: Userform - ComboBox list problem

    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.

  2. #2
    VBAX Regular
    Joined
    Sep 2009
    Posts
    57
    Location
    when you add the items to the combo box do you double click the combo box and then put them under

    [VBA]Private Sub ComboBox1_Change()
    Combobox1.Clear
    Combobox1.AddItem "Item1"
    Combobox1.AddItem "Item2"
    End Sub[/VBA]

    if so try

    [VBA]Private Sub ComboBox1_DropButtonClick()
    Combobox1.Clear
    Combobox1.AddItem "Item1"
    Combobox1.AddItem "Item2"
    End sub[/VBA]

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

  3. #3
    VBAX Regular
    Joined
    Sep 2010
    Posts
    40
    Location
    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
    [VBA]
    Private Sub UserForm_Initialize()
    With Me.ComboBox1
    .additem "a"
    .additem "b"
    End With
    With Me.ComboBox2
    .additem "1"
    .additem "2"
    end with
    End sub[/VBA]

    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

  4. #4
    VBAX Regular
    Joined
    Oct 2010
    Posts
    11
    Location
    i have my userforms set up as below

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

  5. #5
    VBAX Regular
    Joined
    Oct 2010
    Posts
    11
    Location
    hi thanks lehgzil
    i had to put it in a
    [VBA]Private Sub UserForm_Initialize()
    End Sub
    [/VBA]

    thanks heaps

  6. #6
    VBAX Regular
    Joined
    Sep 2010
    Posts
    40
    Location
    try this?

    [vba]Private Sub UserForm_Initialize()
    UserForm1.Controls("combobox1").List = Array("first item", "second item")
    UserForm1.Controls("combobox1").DropDown
    End Sub[/vba] 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

    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...

  7. #7
    VBAX Regular
    Joined
    Oct 2010
    Posts
    11
    Location
    sorry, new to this forum.
    how do i mark as solved?

  8. #8
    VBAX Regular
    Joined
    Sep 2010
    Posts
    40
    Location
    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.. ^_^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •