View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
C[_3_] C[_3_] is offline
external usenet poster
 
Posts: 1
Default dynamically assigning to a combo box

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.