ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboList Source (https://www.excelbanter.com/excel-programming/394877-combolist-source.html)

Mike H.

ComboList Source
 
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?

Anony

ComboList Source
 
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?

------
Cheers,
Anony


"Mike H." wrote:

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?


Mike H.

ComboList Source
 
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.

"Anony" wrote:

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?

------
Cheers,
Anony


"Mike H." wrote:

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?


Dave Peterson

ComboList Source
 
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

Mike H. wrote:

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?


--

Dave Peterson

Dave Peterson

ComboList Source
 
Ps. The headings (.columnheads) can only be used when you use a .rowsource--a
range on a worksheet.



Mike H. wrote:

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?


--

Dave Peterson


All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com