Combobox VBA – populating with items
Comboboxes are user friendly data input forms that can make the difference between a quality looking form and a archaic data input screen.
Defining combobox in Excel
For this step you must go to the Excel Developer menu, make sure you have this menu since it doesn’t come activated in Excel Options. Select the Insert Active-x controls area and choose a combobox to place on your form: click-drag on the position. Right click on it and select Properties in order to give it a custom name (that will be used in VBA code for populating with items) and some visual design changes.
Code for populating combobox VBA
Switch into Visual Basic for Application and get ready to insert the code that adds items to your combobox VBA.
First you need to clear the old contents before inserting new items. This can be done by using the Clear action:
In order to insert items, the Additem action will be used like this:
You can, of course, include this code line in a FOR or WHILE in order to add as many items as you need.