Tutorial Details
Downloadable Files: Excel File
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Multiple Selections in a ListBox

Add to Favorites
Author: | Edits: don

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)

b5da30435a17b22c3c922d42004c4427.png

Sections:

Allow Multiple ListBox Selections by Hand

Allow Multiple ListBox Selections Using VBA

Notes

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.

db3a100cf8c23071773cc53e2fe873e3.png

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).

270dec9c51588f321936f9f57e05901e.png

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.

Question? Ask it in our Excel Forum


Downloadable Files: Excel File