Multiple selections in Listbox

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
 
Z

Zack Barresse

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
 
Top