ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List Box Row Source (https://www.excelbanter.com/excel-programming/384884-list-box-row-source.html)

kirkm[_6_]

List Box Row Source
 
Must the row source property be (e.g.) Reports!A1:D5 ?

Or can you specify individual columns like A1:A5, E1:E5, B1:B5

Thanks - Kirk

Bob Phillips

List Box Row Source
 
No, but you could load the listbox from those ranges.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"kirkm" wrote in message
...
Must the row source property be (e.g.) Reports!A1:D5 ?

Or can you specify individual columns like A1:A5, E1:E5, B1:B5

Thanks - Kirk




JLGWhiz

List Box Row Source
 
Here is a snippet from VBA Help file:

Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 5
ListBox1.RowSource = "a1:e4"
ListBox1.ControlSource = "a6"
'Place the ListIndex into cell a6
ListBox1.BoundColumn = 0
End Sub

Note that the RowSource is a simple five column range in quotes. You can
specify your range with single or multiple columns using RowSource so long as
the columuns are contiguous (side by side). Discontiguous columns must be
handled in an array.


"kirkm" wrote:

Must the row source property be (e.g.) Reports!A1:D5 ?

Or can you specify individual columns like A1:A5, E1:E5, B1:B5

Thanks - Kirk


kirkm[_6_]

List Box Row Source
 
On Thu, 8 Mar 2007 15:54:22 -0800, JLGWhiz
wrote:

Here is a snippet from VBA Help file:

Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 5
ListBox1.RowSource = "a1:e4"
ListBox1.ControlSource = "a6"
'Place the ListIndex into cell a6
ListBox1.BoundColumn = 0
End Sub

Note that the RowSource is a simple five column range in quotes. You can
specify your range with single or multiple columns using RowSource so long as
the columuns are contiguous (side by side). Discontiguous columns must be
handled in an array.


Ok. Thanks. I can make them contiguous to start with.

Could you give me an example of ListIndex? I don't understand that.

Also - another problem. In the cells the numbers are formatted
correctly, but the listbox seems to overide that and present them
left justified. Can I resolve that - or should I use text mode and
leading spaces?

Thanks - Kirk



"kirkm" wrote:

Must the row source property be (e.g.) Reports!A1:D5 ?

Or can you specify individual columns like A1:A5, E1:E5, B1:B5

Thanks - Kirk


JLGWhiz

List Box Row Source
 
You can set the text alignment (right, left or center) in the properties
window of the listbox control when you create it if you are using the control
toolbox for a UserForm. If you are creating it on the worksheet, you will
have to have the control toolbox in design mode to see the properties window.

List index has three different applications. I suggest you use the VBA help
file to review these and decide for yourself what it means. You can access
the VBA help file in the VB editor by pressing Alt+f11, the click on Help in
that window and enter the word ListIndex (one word) in the search box. This
will pull up the menu for you to access the three applications of ListIndex.

"kirkm" wrote:

On Thu, 8 Mar 2007 15:54:22 -0800, JLGWhiz
wrote:

Here is a snippet from VBA Help file:

Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 5
ListBox1.RowSource = "a1:e4"
ListBox1.ControlSource = "a6"
'Place the ListIndex into cell a6
ListBox1.BoundColumn = 0
End Sub

Note that the RowSource is a simple five column range in quotes. You can
specify your range with single or multiple columns using RowSource so long as
the columuns are contiguous (side by side). Discontiguous columns must be
handled in an array.


Ok. Thanks. I can make them contiguous to start with.

Could you give me an example of ListIndex? I don't understand that.

Also - another problem. In the cells the numbers are formatted
correctly, but the listbox seems to overide that and present them
left justified. Can I resolve that - or should I use text mode and
leading spaces?

Thanks - Kirk



"kirkm" wrote:

Must the row source property be (e.g.) Reports!A1:D5 ?

Or can you specify individual columns like A1:A5, E1:E5, B1:B5

Thanks - Kirk



kirkm[_6_]

List Box Row Source
 
On Thu, 8 Mar 2007 17:36:08 -0800, JLGWhiz
wrote:

You can set the text alignment (right, left or center) in the properties
window of the listbox control when you create it if you are using the control
toolbox for a UserForm.



It's only the numbers I want right justified, not the text.
Can you apply justification on a column by column basis?


List index has three different applications. I suggest you use the VBA help
file to review these and decide for yourself what it means.


I can't understand much of Help in any Microsoft application. It's
really no help to a beginner becuise the terms they use are
meaningless.

Cheers - Kirk



All times are GMT +1. The time now is 12:55 PM.

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