Subscribe for Weekly Tutorials
BONUS: subscribe now to download our Top Tutorials Ebook!
Multiple Selections in a ListBox
There are two different kinds of multiple item selections that you can have for a ListBox in a UserForm in Excel.
One method works when you click any item in the ListBox and the other works only when you hold down Ctrl or Shift while clicking items; both will be explained below and we will use the MultiSelect property to do this.
(To get data from a multi-select ListBox, view this tutorial: Get Data from a ListBox Control)
Sections:
Allow Multiple ListBox Selections by Hand
Allow Multiple ListBox Selections Using VBA
Allow Multiple ListBox Selections by Hand
Change the MultiSelect property for the ListBox.
Go to the VBA window (Alt + F11) > open the form by double-clicking it in the Project Explorer window (Ctrl + R) > click the ListBox > look at the Properties Window (F4) and go to the MultiSelect property.
0 - fmMultiSelectSingle means that only 1 option at a time may be selected.
1 - fmMultiSelectMulti means that each item you click in the ListBox will be selected until you click it again to de-select that item.
2 - fmMultiSelectExtended means that multiple items will be selected only when you hold down the Ctrl button or Shift key. While holding the Shift key, you can select a group of items together by clicking the first item, holding Shift, and then moving to the last item that you want to select and clicking it.
Allow Multiple ListBox Selections Using VBA
Allow multiple selections with Ctrl and Shift:
ListBox1.MultiSelect = fmMultiSelectExtended
Allow multiple selections by clicking the items:
ListBox1.MultiSelect = fmMultiSelectMulti
Allow only a single selection from the ListBox:
ListBox1.MultiSelect = fmMultiSelectSingle
ListBox1 is the name of the ListBox.
fmMultiSelectSingle means that only 1 option at a time may be selected.
fmMultiSelectMulti means that each item you click in the ListBox will be selected until you click it again to de-select that item.
fmMultiSelectExtended means that multiple items will be selected only when you hold down the Ctrl button or Shift key. While holding the Shift key, you can select a group of items together by clicking the first item, holding Shift, and then moving to the last item that you want to select and clicking it.
Where to Put this:
Put this code inside the UserForm Initialize section of code (the code that runs when the form starts up).
Notes
This is a fairly easy thing to setup, just don't forget that the name of the property that controls this feature is MultiSelect.
Download the sample file for this tutorial so you can work with this example in Excel.