Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox Column Headers name

Status
Not open for further replies.

Totte

Programmer
Jun 6, 2001
317
SE
As a fairly beginner in VBA in Excel i'm almost about to give up. I have a normal ListBox with 4 columns, has enabled the 'ColumnHeads' feature and like to put some values into those columnheads.....but HOW???

I'm trying to get hold of MSDN but it will take some time and i'm sure some of You guys knows it.

And yes, i haven't programmed all that much VBA but has several years in BCB and ANSI C so it's not the programming habit it's low on, just the exact knowledge.

Any help is appreciated.

Totte
 
Listbox headers work only when the source data is an excel range (rowsource property), otherwise ColumnHeads setting has no effect.

combo
 
OK, so it's impossible to do something like:
ListBox1.Column = 1
ListBox1.ColumnHead.Text = "Date"
ListBox1.Column = 2
ListBox1.ColumnHead.Text = "Day"
ListBox1.Column = 3
ListBox1.ColumnHead.Text = "Total"
ListBox1.Column = 4
ListBox1.ColumnHead.Text = "Speeding"

Please read 'ListBox1.ColumnHead.Text' as the way to set the header name for a column.

I MUST write the headernames in an Excel-range and then set it in?

Totte
 
AFAIK - yes, not only the headers but full list. You have to assign excel range to RowRource property, for instance:
=Sheet1!A2:B5 ' uses address
=RangeName ' uses named range
When you set ColumnHeads to True, ListBox takes the cells above this range (or column name if table starts in 1st row) as titles.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top