Name

control.AddItem(Item[, Index])

Synopsis

Adds an item to the list.

Argument

Settings

Item

The item to add.

Index

The position of the item in the list. Default is to add the item to the end of the list.

The following code adds three items to a drop-down list and selects the first item:

Private Sub UserForm_Initialize(  )
    ComboBox1.AddItem "this"
    ComboBox1.AddItem "that"
    ComboBox1.AddItem "other"
    ComboBox1.Style = fmStyleDropDownList
    ComboBox1.ListIndex = 1
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.