VBA-Excel How to clear ComboBox Items

2019-07-27 03:24发布

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.

标签: excel vba
1条回答
smile是对你的礼貌
2楼-- · 2019-07-27 04:16

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
查看更多
登录 后发表回答