Is it possible to retrieve the selected values from a multiselect list box (not active X)?

2

Is it possible to retrieve the selected values from a list box (Form Control) with the multiple selection option, by formula or Vba?

    
asked by anonymous 09.01.2017 / 14:03

1 answer

2

Yes, it is possible. You should create a loop to check each of the items in the listbox and do what you want.

COD 1

Dim k As Long
Dim s As String

For k = 0 To List1.ListCount - 1
    If List1.Selected(k) Then
        s = List1.List(k)
        ' ... fazer algo com o item selecionado
    End If
Next

COD 2

Dim lItem As Long

For lItem = 0 To List1.ListCount - 1    
    If List1.Selected(lItem) = True Then    
        MsgBox(List1.List(lItem))    
    End If    
Next    

Or, if these above codes do not work, you can try running the proposed template in that answer .

EDIT: to learn how to manipulate list boxes, take a look at in this link .

    
09.01.2017 / 14:16