Count the number of selected items in a ListBox

0

I have a ListBox1 list in a userform configured for multiple item selection. Is there a function, statement or way to return the number of selected items?

    
asked by anonymous 27.04.2017 / 20:21

1 answer

2

I think this code should help you.

Dim intIndex As Integer 
Dim intCount As Integer 

With ListBox1 
    For intIndex = 0 To .ListCount - 1 
        If .Selected(intIndex) Then intCount = intCount + 1 
    Next 
End With 
Label1.Caption = "Selecionados " & intCount & " de " & ListBox1.ListCount 
    
27.04.2017 / 20:54