J
Jay Freedman
Hi duBedat,
To allow multiple selections in the list, you must use a listbox
control instead of a combobox.
The initialization of the listbox will be exactly like the one you
have for the combobox. In the Properties pane for the listbox, change
the value of the MultiSelect property to fmMultiSelectExtended -- or
you can do this in code by including this line inside the With group
in the Userform_Initialize procedure:
.MultiSelect = fmMultiSelectExtended
This will also change the way you "read" the selected items when the
user clicks the OK button. When you have a single-selection listbox or
a combobox, you would read the selected item from the .Value property
or get its index from the .ListIndex property, but that doesn't work
when multiple selection is allowed. Instead, you need to loop through
all the indexes and note which ones are indicated by .Selected(index)
= True. See the example in the VBA help for the Selected property.
To allow multiple selections in the list, you must use a listbox
control instead of a combobox.
The initialization of the listbox will be exactly like the one you
have for the combobox. In the Properties pane for the listbox, change
the value of the MultiSelect property to fmMultiSelectExtended -- or
you can do this in code by including this line inside the With group
in the Userform_Initialize procedure:
.MultiSelect = fmMultiSelectExtended
This will also change the way you "read" the selected items when the
user clicks the OK button. When you have a single-selection listbox or
a combobox, you would read the selected item from the .Value property
or get its index from the .ListIndex property, but that doesn't work
when multiple selection is allowed. Instead, you need to loop through
all the indexes and note which ones are indicated by .Selected(index)
= True. See the example in the VBA help for the Selected property.