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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to edit column headers?

Status
Not open for further replies.

WebStar

Programmer
May 1, 2002
69
DE
I have a list box in a form and I want to name the columns so I set ColumnHeads on true but how can write something in there?
Thank you!
 
Hi WebStar,

In Excel, the headings come from the row above your RowSource range, so if your RowSource is A2:C10, for example, put the headings you want in cells A1:C1.

Enjoy,
Tony
 
ok thank you, I got that but if one of my columns in the listbox is filled up from several columns in Excel?
 
Hi WebStar,

I don't know of any way to programmatically change the headings.

The only way I can think of is to build your complete list and just befoe you show the form, copy it somewhere in a worksheet and add the headings you want, and then set the RowSource to it, something like this in the activate event perhaps:

Code:
Me.ListBox1.RowSource = ""

Me.ListBox1.AddItem
Me.ListBox1.AddItem
Me.ListBox1.AddItem
Me.ListBox1.AddItem
Me.ListBox1.AddItem
Me.ListBox1.AddItem

Me.ListBox1.Column(0, 0) = "qq"
Me.ListBox1.Column(0, 1) = "ww"
Me.ListBox1.Column(0, 2) = "ee"
Me.ListBox1.Column(0, 3) = "rr"
Me.ListBox1.Column(0, 4) = "tt"
Me.ListBox1.Column(0, 5) = "yy"

Me.ListBox1.Column(1, 0) = "aa"
Me.ListBox1.Column(1, 1) = "ss"
Me.ListBox1.Column(1, 2) = "dd"
Me.ListBox1.Column(1, 3) = "ff"
Me.ListBox1.Column(1, 4) = "gg"
Me.ListBox1.Column(1, 5) = "hh"

Me.ListBox1.Column(2, 0) = "zz"
Me.ListBox1.Column(2, 1) = "xx"
Me.ListBox1.Column(2, 2) = "cc"
Me.ListBox1.Column(2, 3) = "vv"
Me.ListBox1.Column(2, 4) = "bb"
Me.ListBox1.Column(2, 5) = "nn"

[a2:c7] = Me.ListBox1.List
[a1:c1] = Array("Head1", "Head2", "Head3")

Me.ListBox1.RowSource = "a2:c7"
Me.ListBox1.ColumnHeads = True

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top