Vba setup list box in Excel

For example, I have a Activex listbox "Countries". I want to allow users to select more than one country in the list.

excel vba setup list box

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub EnableListBoxMultiSelect()
  3. ActiveSheet.Countries.MultiSelect = fmMultiSelectMulti
  4. End Sub

Description:

a) Line 3 sets up the ListBox to support multiple values selection by user.

b) To support only one value selection, the MultiSelect propert should be set to "fmMultiSelectSingle" instead of "fmMultiSelectMulti"

 

You can find similar Excel Questions and Answer hereunder

1) Introduction to tables in Excel VBA and how to use tables, create tables in VBA

2) How to create charts in Excel VBA

3) Tables in Excel VBA. How you can create table in VBA and work with them with macros

4) How can I copy and rename a WorkSheet using VBA?

5) Vba clear the contents of an entire sheet in Excel

6) How do I enter a formula in a cell using VBA (using Relative Reference)?

7) How can I filter and copy only filtered data using VBA?

8) How can I set Page orientation, Zoom % , Title Rows and footer using VBA?

9) How can I prevent users from seeing / accessing my macro code?

10) Vba delete entire row if contains certain text in Excel

 

Here the previous and next chapter