List Boxes

matthew230

Board Regular
Joined
Jan 2, 2006
Messages
152
Hi,

Can anybody give me some guidance on using list boxes with multiple selection.

For example if I want to extract the value from a combobox I use:

strVariable = userform1.combobox1.value

or something similar.

How can I use list boxes in a similar manner ?

Many thanks

Matt
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,348
Code:
With ListBox1
    For i = 1 to .ListCount -1
        If .Selected(i) Then MsgBox .List(i) & " is one of the selected items."
    Next i
End With
 
Upvote 0

matthew230

Board Regular
Joined
Jan 2, 2006
Messages
152
Code:
With ListBox1
    For i = 1 to .ListCount -1
        If .Selected(i) Then MsgBox .List(i) & " is one of the selected items."
    Next i
End With


Hi,

I've had a lilttle play this.

I had to alter i = 0 for it to pick up all selections. I guess that the first line is denoted as zero rather than one
 
Upvote 0

Forum statistics

Threads
1,190,764
Messages
5,982,797
Members
439,798
Latest member
tangojuliet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top