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

1.Value

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.

2.Style

This property is used to specify how the control should look like.

There are three values

1.vbComboDropdown
2.vbComboSimple
3.vbComboList

 

3.Items

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.

4.Index

This property specifies the index of the items in the combobox.

The index starts with 0 and -1 specifies an empty list.

5.Font Property

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.

  1. Private Sub ComboBox1_Change()
  2. MsgBox ComboBox1.Value
  3. End Sub
  4. excel vba combobox interfacing

 

You can find similar Excel Questions and Answer hereunder

1) Here an explanation about text box and how to control text boxes in Excel VBA

2) What are ActiveX controls in VBA. Here some good explanations

3) Here an explanation about the options in button control in Excel VBA

4) Here an explanation about list box and how to control list boxes in Excel VBA

5) Here an explanation about spin button and how to control it using VBA

6) How to control forms in Excel VBA

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

8) Here an explanation about checkbox and how to control checkboxes in Excel VBA

9) In Excel we use forms to interface with the user. Here some basics about GUI or graphical user interface

10) Here an explanation about frames and how to control frames in Excel VBA

 

Here the previous and next chapter