How to populate a combo box with specified data on Workbook open?
Normally, you can fill a combo box (ActiveX Control) with a certain range of cell data by entering the cell references into the ListFillRange field of the combo box properties. If you want to populate a combo box with specified data directly without manually specifying its properties, the method in this article can help you.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
This method can help you populate a combo box with specified data directly on workbook open. Please do as follows.
1. Press the Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, double-click ThisWorkbook in the left pane to open the ThisWorkbook code editor. And then copy below VBA code into it. See screenshot:
VBA code: populate a combo box with specified data on workbook open
Private Sub Workbook_Open() 'Updated by Extendoffice 2018/1/30 With Sheet1.ComboBox1 .Clear .AddItem "Select a Fruit" .AddItem "Apple" .AddItem "Banana" .AddItem "Peach" .AddItem "Pineapple" .AddItem "Watermelon" .Text = .List(0) End With End Sub
1). ComboBox1 is the name of the combo box you will fill data, and this combo box locates in Sheet1. Please change them as you need.
2). And replace the data in the code with your needed one.
3. Save the workbook as Excel Macro-Enabled Workbook format and close it.
4. Reopen the workbook, you will see the combo box has been populated with specified data as below screenshot:
- How to copy Combo Box value to active cell in Excel?
- How to display date format in combo box output in Excel?
- How to prevent or disable typing in a combo box in Excel?
- How to populate Combo Box with data of Named Range in Excel?