Select a row from the listbox object

1

I have a spreadsheet (PLan1), with its cells listed in listbox1 , I would like to capture a row with multiple cells of information and list it in userform , how should I do it?

    
asked by anonymous 10.06.2015 / 20:37

1 answer

1

I think the best solution would be to use a ComboBox on the UserForm.

My suggestion is to follow the steps below:

  • Create a table and name a range (eg lst_Sports)

  • Create a form and code to load the data at form initialization, how to do this? Here is a code and a spreadsheet template I made to answer this question.

  • Code:

    Private Sub btn_populate_Click()
    ' Botão para carregar os dados
    
    ' Limpa os dados do combobox
    cmb_esporte.Clear
    
    ' Busca os dados que irá para a lista
    Dados = Range("lst_Esporte")
    
    ' Carrega os dados no combobox
    With cmb_esporte
        For Each Item In Dados
        .AddItem Item
        Next Item
    End With
    
    ' Coloque valor padrão - caso aplicável
    cmb_esporte.Value = "Escolha sua opção"
    
    End Sub
    

    Link to the template I made: template

    I hope I have helped!

        
    22.06.2015 / 22:55