ComboList Source

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to set the rowSource Property (The list of the combo box that pops up
when you click the pulldown) to an array that is already built. I try to
type the name of the array in the box but it doesn't allow that. What am I
missing here?
Also, how would the array be set up so that the titles of the columns of
data have a heading?
 
This doesn't make use of the rowsource property, but it does the same thing.

Private Sub AddArray()
Dim i As Long
'Your array should already be filled at this point
For i = 0 To UBound(MyArray)
UserForm1.ComboBox1.AddItem MyArray(i)
Next i
End Sub

I don't quite understand your question regarding the headers. You need the
titles where?
 
Your suggestion will satisfy this issue. Regarding the header, that is if I
could display multiple rows of data in the list of data to select from, but
that is now how this object works, so the question is not relevant. Thanks
again for your suggestion.
 
Maybe...

Option Explicit
Private Sub UserForm_Initialize()
dim myArr as Variant
'some test data
myArr = worksheets("sheet999").range("a1:A10").value
'assign the array directly to the list.
Me.Combobox1.List = myArr
End Sub
 
Ps. The headings (.columnheads) can only be used when you use a .rowsource--a
range on a worksheet.
 

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

Back
Top