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
This property specifies, whether multiple values can be selected from the control.
This is either 0,1 or 2.
This property specifies the list style of the control.
The values are:
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:
- Private Sub ListBox1_Change()
- MsgBox "Selection changed"
- End Sub