Clear Method

Microsoft Office Visual Basic

Removes all list items from a command bar combo box control (drop-down list box or combo box) and clears the text box (edit box or combo box).

Note  This method will fail if it's applied to a built-in command bar control.

expression.Clear

expression    Required. An expression that returns a CommandBarComboBox object.

Example

This example checks the number of items in the combo box control on the command bar named "Custom." If there are fewer than three items in the list in the combo box, the example clears the list, adds a new first item to the list, and then displays this new item as the default for the combo box control.

Set myBar = CommandBars("Custom Bar")
Set myControl = myBar.Controls _
    Type:=msoControlComboBox)
With myControl
    .AddItem "First Item", 1
    .AddItem "Second Item", 2
End With
If myControl.ListCount < 3 Then
    myControl.Clear
    myControl.AddItem Text:="New Item", Index:=1
End If