Select a row of the listbox object

Asked

Viewed 1,565 times

1

I have a spreadsheet (Plan1), with its cells listed in a listbox1, would like to capture a line with several information cells and list it in a userform, how should I do?

1 answer

1

I believe that the best solution would be to use a Combobox in Userform.

My suggestion is to follow the steps below:

  1. Create a table and name a range (e.g. lst_Esporte)

  2. Create a form and encode to load the data on the form startup, how to do this? Below 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 with the model I made: model

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.