ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   listbox problem #2 (https://www.excelbanter.com/excel-programming/327269-listbox-problem-2-a.html)

keith

listbox problem #2
 
Thank you to those who replied to my question about
changing list box text. The comments were very helpful.
Today I need to put text into the listbox column
headings. The listbox property has been set to show
three columns. Using help, I have been unable to find a
code statement that will do this. Any suggestions?

Keith

Harald Staff

listbox problem #2
 
Hi Keith

You can't do that by code. Listbox column headers appear only when you
populate the box with a spreadsheet range that has columnheaders.

HTH. Best wishes Harald

"Keith" skrev i melding
...
Thank you to those who replied to my question about
changing list box text. The comments were very helpful.
Today I need to put text into the listbox column
headings. The listbox property has been set to show
three columns. Using help, I have been unable to find a
code statement that will do this. Any suggestions?

Keith




Dave Peterson[_5_]

listbox problem #2
 
I don't recall the "listbox problem 1" question (maybe the OP was looping
through the range to selectively add stuff to the listbox????).

But I can use code and have headers:

Option Explicit
Private Sub UserForm_Activate()
With Me.ListBox1
.ColumnCount = 3
.RowSource _
= Worksheets("Sheet1").Range("a2:c10").Address(exter nal:=True)
.ColumnHeads = True
End With
End Sub

(I figure there was a lot of stuff from the original thread that I missed).

=====
To the OP:

Maybe you could add some labels right above the listbox and use them for
headers.

Harald Staff wrote:

Hi Keith

You can't do that by code. Listbox column headers appear only when you
populate the box with a spreadsheet range that has columnheaders.

HTH. Best wishes Harald

"Keith" skrev i melding
...
Thank you to those who replied to my question about
changing list box text. The comments were very helpful.
Today I need to put text into the listbox column
headings. The listbox property has been set to show
three columns. Using help, I have been unable to find a
code statement that will do this. Any suggestions?

Keith


--

Dave Peterson

Harald Staff

listbox problem #2
 
"Dave Peterson" skrev i melding
...

But I can use code and have headers:


Bad choice of words from me, sorry. Yes, one can set the Rowsource /
Listfillrange by code also. But one can not have columnheaders if the list
is populated using VBA code .Additem or .List

Best wishes Harald



Dave Peterson[_5_]

listbox problem #2
 
Excellent choice of words this time <bg.

Harald Staff wrote:

"Dave Peterson" skrev i melding
...

But I can use code and have headers:


Bad choice of words from me, sorry. Yes, one can set the Rowsource /
Listfillrange by code also. But one can not have columnheaders if the list
is populated using VBA code .Additem or .List

Best wishes Harald


--

Dave Peterson


All times are GMT +1. The time now is 09:22 AM.

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