Multiple selections in Listbox

  • Thread starter Thread starter Christiaan
  • Start date Start date
C

Christiaan

I have 2 Excel VBA questions:
1) Is it possible to choose multiple items in a List Box and if so, 2) how
can I use those selected items in a macro (which variable type should I
use?)

For example. I have selected three country in a listbox and I want to print
the sales results of each of those three countries. Asume in this case that
I use for each country one worksheet.

Your suggestions and tips are very appreciated! Thanks!

Best regards,

Christiaan
 
Hi there,

It depends on what kind of listbox you have created. If you have created
one from the Controls Toolbox menu (an ActiveX control), you could use
something like this ...

Sub PrintListBoxSheets()
Dim i As Long
With Sheet1.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
Debug.Print .List(i)
End If
Next i
End With
End Sub

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top