dynamically assigning to a combo box

C

C

Forgive me as I am new to VB. I am trying to assign items to multiple combo
box lists, selecting the combo box dynamically. There has to be a very
simple way to set a string or value into the parent object of the combo box
that will then dynamically set the combo box object itself. In a simple
version, I am trying to set values into combo boxes named ProductList1 to
ProductList10:

Private Sub LoadComboBox_Click()
Dim i As Integer
For Each validcell In Worksheets("Product List").Range("A2:A100")
For i = 1 To 10
If validcell.Value > 0 Then

' This of course will work
ProductList1.AddItem validcell

' As will this
Me.[ProductList1].AddItem validcell

' What I need is this
Me.["ProductList" & i].AddItem validcell

End If
Next i
Next cell
End Sub

This has to be an easy solution, I am just not familiar with the syntax.
Many thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top