Count the number of selected items in a Listbox

Asked

Viewed 1,926 times

0

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

1 answer

2

I believe that 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 
  • Thanks, @andrepaulo. It works! But it only has to run a loop anyway?

  • 1

    to what I know. That’s it. ...

Browser other questions tagged

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