Ad Clicks :Ad Views : Ad Clicks :Ad Views : Ad Clicks :Ad Views : Ad Clicks :Ad Views :
    Excel formulas and tutorials

    Excel formulas and useful tools

    Home / VBA / Combobox VBA – populating with items

    Combobox VBA – populating with items

    /
    /
    /
    1163 Views

    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

    Insert Combobox 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.

    Combobox name

    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:

    Sheets(“Book1”).MyCombo.Clear

    In order to insert items, the Additem action will be used like this:

    Sheets(“Book1”).MyCombo.AddItem “NewItem”

    You can, of course, include this code line in a FOR or WHILE in order to add as many items as you need.

     
    • Facebook
    • Twitter
    • Google+
    • Linkedin
    • Pinterest

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    This div height required for enabling the sticky sidebar