Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Populating a combobox on a userform from a range of cells

Tags:

excel

vba

I am trying to populate a combobox with a range of cells from another sheet in my workbook (called "Other").

I use the following as a guide, but it is not seeming to work. Can anyone offer me advice? When i run the userform, the combobox is not populated with anything.

Private Sub ComboBox1_Change()
    Me.ComboBox1.List = Worksheets("Other").range("C2:C11").Value
End Sub
like image 686
Rivers31334 Avatar asked Mar 15 '23 08:03

Rivers31334


1 Answers

You are using the wrong event procedure ComboBox1_Change. This fires only when the combobox changes value.

Instead, load the list when the userform initializes:

Private Sub UserForm_Initialize()
    ComboBox1.List = [Other!C2:C11].Value
End Sub
like image 68
Excel Hero Avatar answered Mar 23 '23 07:03

Excel Hero