PDA

View Full Version : list box



maryam
01-15-2007, 04:28 AM
how can I have a column head in a list box control and write the head for it?
In List box proeprties I make column head true but cannot write the head (title). When I click on Run it does not show the column head!

Charlize
01-15-2007, 06:16 AM
I believe you can only use columnheads when you specify a rowsource and not by using a list (as an array) to fill the listbox. Maybe use a label above the listbox ?

Charlize

lucas
01-15-2007, 09:48 AM
Hi Mary,
This has been moved to the Excel help forum....I'm not sure it's for excel but I'm pretty sure it's not an announcement which is where you posted it. Please post in the appropriate forum.

Bob Phillips
01-15-2007, 10:18 AM
As Charlize says, you have to specify the data as a range on a worksheet using RowSource, but also do NOT include the heading row in that raneg, the listbox wiull automatically pick up the row above.

Charlize
01-16-2007, 03:31 AM
try this one (insert in form_activate). Only one column of data, here A, will be filled in the listbox.
Private Sub UserForm_Activate()
'change listbox1 to the name of your control
Me.ListBox1.ColumnHeads = True
Me.ListBox1.RowSource = "A2:A" & Range("A" & Rows.Count).End(xlUp).Row
End Sub
Charlize

maryam
01-16-2007, 06:27 AM
Dear All,
Thank you. My problem of the column head is solved by Rowsource that you taught me.
Another question: Is it possible for the user to input data into the list box directly or the data should come from another combobox or list box?

Bob Phillips
01-16-2007, 06:34 AM
No, you should use a textbox, and update the source data. If you use a dynamic named range, you shouldn't need to reset the RowSource property.

maryam
01-16-2007, 06:40 AM
Dear Xld,
Do you know any table liked control in which the user can input data into a table? I tried DataGrid and MSFlex Grid controls but I cannot input data directly into the cells of these controls.

Pete634
05-28-2007, 07:33 PM
try this one (insert in form_activate). Only one column of data, here A, will be filled in the listbox.
Private Sub UserForm_Activate()
'change listbox1 to the name of your control
Me.ListBox1.ColumnHeads = True
Me.ListBox1.RowSource = "A2:A" & Range("A" & Rows.Count).End(xlUp).Row
End Sub
Charlize

I tried this in my search engine and it worked perfectly, first time. However, if I run the search again, it displays an error about not being able to set the column widths property. Is this because I need to empty the listbox and if so, how do I do this?

Note, I didn't put the above code in Userform_Activate,instead it appears in my commandbutton (called search funnily!)