Select an item in a combobox

Solved
hich24 Posted messages 1686 Status Member -  
hich24 Posted messages 1686 Status Member -
Hello,
I have a combo box with items placed on a user form, and I would like to add a command button that selects a specific item in the combo box.
The problem is that I can't create a macro that searches for the item in the combo box.

Thank you in advance for your time.

3 answers

  1. cs_Le Pivert Posted messages 8437 Status Contributor 730
     
    Hello,

    see this:

    https://silkyroad.developpez.com/VBA/ControlesUserForm/#LII-F

     ComboBox1.ListIndex = 5 'selects the 6th item(the list starts at 0) MsgBox ComboBox1.Value 'value of the selected item


    --
    @+ The Woodpecker
    1
    1. hich24 Posted messages 1686 Status Member 753
       
      Thank you, but I first need to find the index of the word in the combo box and then select it.
      0