ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RowSource as a row (https://www.excelbanter.com/excel-programming/393458-rowsource-row.html)

Boba

RowSource as a row
 
Hi;
what is the proper syntax for RowSource:
ListBox1.RowSource=Range("A1:L1")
gives me just A1 cell as the only element
in the ListBox.List. Thanks. Boba



Gary Keramidas

RowSource as a row
 
you can try this

Private Sub UserForm_Activate()
Dim ws As Worksheet
Dim i As Long
Set ws = Worksheets("Sheet1")
For i = 1 To 12
Me.ListBox1.AddItem ws.Cells(1, i)
Next
End Sub

--


Gary


"Boba" wrote in message
...
Hi;
what is the proper syntax for RowSource:
ListBox1.RowSource=Range("A1:L1")
gives me just A1 cell as the only element
in the ListBox.List. Thanks. Boba




Dave Peterson

RowSource as a row
 
You only have one row in A1:L1.

If you want each of the values in A1:L1 as your list:

listbox1.list = application.transpose(range("a1:L1").value)



Boba wrote:

Hi;
what is the proper syntax for RowSource:
ListBox1.RowSource=Range("A1:L1")
gives me just A1 cell as the only element
in the ListBox.List. Thanks. Boba


--

Dave Peterson

Jim Thomlinson

RowSource as a row
 
Try something more like this...

ListBox1.RowSource=Sheets("Sheet1").Range("A1:L1") .Address
--
HTH...

Jim Thomlinson


"Boba" wrote:

Hi;
what is the proper syntax for RowSource:
ListBox1.RowSource=Range("A1:L1")
gives me just A1 cell as the only element
in the ListBox.List. Thanks. Boba




Jim Thomlinson

RowSource as a row
 
My code does not work (in retrospect). Use Dave's
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Try something more like this...

ListBox1.RowSource=Sheets("Sheet1").Range("A1:L1") .Address
--
HTH...

Jim Thomlinson


"Boba" wrote:

Hi;
what is the proper syntax for RowSource:
ListBox1.RowSource=Range("A1:L1")
gives me just A1 cell as the only element
in the ListBox.List. Thanks. Boba





All times are GMT +1. The time now is 10:19 AM.

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