Vba list box control in Excel

The listbox control is used to display a list of values to the user.

The user can select the required value from the list box.

This control is similar to the combobox control except that, there is no dropdown option.

This control displays all the items and if the number of items exceed the size of the control,

then a scrollbar is added automatically.

Properties of listbox control

The listbox control has all the common properties of a combobox and other controls

Apart from these, some of the properties that are unique to a listbox is discussed below

1.Multiselect property

This property specifies, whether multiple values can be selected from the control.

This is either 0,1 or 2.

2.Liststyle property

This property specifies the list style of the control.

The values are:

0-Plain text

1-Text with Checkbox

Events associated with Listbox

The most commonly used event is Change event.

This event is triggered whenever a listbox item selection is changed.

The following code illustrates this:

  1. Private Sub ListBox1_Change()
  2. MsgBox "Selection changed"
  3. End Sub

excel vba list box control

 

You can find similar Excel Questions and Answer hereunder

1) How can I set up a drop down list?

2) Here an explanation about label controls in the various forms and controls using VBA

3) Vba list all files in a folder in Excel

4) How can I get users to select a file for processing using my macro?

5) Applying a countif formula only to visible cells in a filtered list in Excel

6) How to control forms in Excel VBA

7) How to get user input in VBA with the inputbox function

8) How can I set up ListBox using VBA to allow users to select multiple values?

9) How do I update my DropDown list whenever the sheet is activated?

10) Here an explanation about buttons in VBA

 

Here the previous and next chapter