Search code examples
excelvbacombobox

VBA add incremented values into combobox


| am wondering how to populate items list for a combobox from value to value by increment of value? The way I do it now is by hand via:

LowerFilmWidth_ComboBox.AddItem "300"

In this example I am trying to add values from 300 to 650 by increment of 1

Could someone, please, share a code for doing that?


Solution

  • If you want to be fancy, you could use something like:

    LowerFilmWidth_ComboBox.List = [Row(300:650)]
    

    But for future reference you should know about the For loop where you could Step through in a specified interval (1 by default)

    For x = 300 To 650 'Step 1
        LowerFilmWidth_ComboBox.AddItem x
    Next