SaiKiran Mandhala
SaiKiran Mandhala

Reputation: 365

VBA-Excel How to clear ComboBox Items

i have a ComboBox with 3 items as "Select","Jack" and "Jill". Under Private Sub Workbook_Open() I kept the following lines of code.

With ThisWorkbook.Sheets("Sheet1").ComboBox1
    Items.Clear
    .AddItem "Select"
    .AddItem "Jack"
    .AddItem "Jill"
End With

When ever i select an item and close the excel. Next time if i open the excel by default comboBox showing the previously selected item. But i want to show select as a default item.

Upvotes: 2

Views: 119916

Answers (1)

Sorceri
Sorceri

Reputation: 8033

You need to remove Items.Clear should be just .Clear and then use .SelText property to set the selected text

With ThisWorkbook.Sheets("Sheet1").ComboBox1
    .Clear
    .AddItem "Select"
    .AddItem "Jack"
    .AddItem "Jill"
    .SelText = "Select"
End With

Upvotes: 16

Related Questions