ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RowSource property in cbox (https://www.excelbanter.com/excel-programming/442736-rowsource-property-cbox.html)

Sam

RowSource property in cbox
 
I have a horizontal range named "TranList" that I want to use as the
RowSource of a UserForm combo box. I tried entering the range name into the
RowSource property and using the Transpose function for the range in
UserForm_Initialize but can't seem to get it to work.

Any help would be appreciated.

Thanks,

Sam

Rick Rothstein

RowSource property in cbox
 
A horizontal range can't be a RowSource (no rows). You will have to loop the
range to populate your ComboBox. Something like this (change the name of the
ComboBox to whatever yours is named)...

Dim V As Variant
For Each V In Range("TranList")
Me.ComboBox1.AddItem V
Next

--
Rick (MVP - Excel)



"Sam" wrote in message
...
I have a horizontal range named "TranList" that I want to use as the
RowSource of a UserForm combo box. I tried entering the range name into
the
RowSource property and using the Transpose function for the range in
UserForm_Initialize but can't seem to get it to work.

Any help would be appreciated.

Thanks,

Sam



Matthew Herbert[_3_]

RowSource property in cbox
 
Sam,

You can use a named range for .RowSource. Take note that the help file
instructs that .RowSource accepts a String. A ListBox should be fine with a
horizontal range, but if the ComboBox isn't then you'll have to load the
ComboBox some other way(i.e. you wouldn't use .RowSource). So, you can use
something like the following on a ListBox1:

Me.ListBox1.RowSource = Range("NamedRange").Address(External:=True)

Apply this same concept to your ComboBox to test whether it will work. If
it doesn't work, then you'll have to load the ComboBox some other way (i.e.
..List, .AddItem, etc.).

Best,

Matthew Herbert

"Sam" wrote:

I have a horizontal range named "TranList" that I want to use as the
RowSource of a UserForm combo box. I tried entering the range name into the
RowSource property and using the Transpose function for the range in
UserForm_Initialize but can't seem to get it to work.

Any help would be appreciated.

Thanks,

Sam


B Lynn B

RowSource property in cbox
 
You could leave the RowSource property empty, and run some alternate code
during initialization as follows:

dim CL as range

For Each CL in Range("BoxSource").Cells
ComboBox1.AddItem CL
Next CL

Change range to whatever you've called yours, and ComboBox1 to the actual
name of your combobox.

"Sam" wrote:

I have a horizontal range named "TranList" that I want to use as the
RowSource of a UserForm combo box. I tried entering the range name into the
RowSource property and using the Transpose function for the range in
UserForm_Initialize but can't seem to get it to work.

Any help would be appreciated.

Thanks,

Sam



All times are GMT +1. The time now is 07:54 PM.

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