Vba combobox interfacing in Excel
A combo box controls has the functionality of both text box and a list box.
This control is most often used in many applications.
Combo box allows the user to select an item either by typing it or by choosing from the list.
This control s most efficient, when a selection of text without any spell mismatch is required in the application.
The control presents a list of choices to the user.
If the list exceeds the size of the control, a scrollbar will automatically be added.
Properties of Combobox
This property is used to either get or set the value of the combobox control.
It is nothing but the curently selected item in the control.
This property is used to specify how the control should look like.
There are three values
This property is used to get the list of items I the combobox.
The Add() method associated with this property is used to add new items to the control.
This property specifies the index of the items in the combobox.
The index starts with 0 and -1 specifies an empty list.
This property is used to set the font of the items in the list.
Events associated with Combobox:
The important and often used event associated with the combobox is "Change" event.
This event is triggered whenever a selection is made in the combobox.
The following example illustrates this.
- Private Sub ComboBox1_Change()
- MsgBox ComboBox1.Value
- End Sub