ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Title heading in Listbox1 (https://www.excelbanter.com/excel-programming/378339-title-heading-listbox1.html)

John

Title heading in Listbox1
 
Hi,

Searched the archives and found a similar question, though the answers
whilst useful did not sovle my problem, so posting hte question again.

How using VBA can i make the text in D1 the Header in my Listbox. I'm using
VBA to build the Rowsource. I know if i were to set this manually in the
Rowsource then the text in D1 appears as the column heading in the Listbox,
but as each Item comes from filtered data, even though D1 is outside of the
filtered data range, D1 appears as the first Item in the Listbox.

Mike Milligan posted a similar question back in October this year (I think!)
under the title "Adding Headers To A Listbox"

All help on this gratefully appreciated.

Thanks

John


JLGWhiz

Title heading in Listbox1
 
I got this in the VBA help. You can play with it and see if it will adapt to
a ListBox. I have not tried it, but the combobox and listbox both use
AddItem method, so I imagine it will work. First run this example on a
UserForm with a combobox to see if it does what you want. If it does, then
maybe you can adapt.

Set myBar = CommandBars("Custom")
Set myControl = myBar.Controls.Add(Type:=msoControlComboBox)
With myControl
.AddItem Text:="First Item", Index:=1
.AddItem Text:="Second Item", Index:=2
.DropDownLines = 3
.DropDownWidth = 75
.ListHeaderCount = 1
End With


"John" wrote:

Hi,

Searched the archives and found a similar question, though the answers
whilst useful did not sovle my problem, so posting hte question again.

How using VBA can i make the text in D1 the Header in my Listbox. I'm using
VBA to build the Rowsource. I know if i were to set this manually in the
Rowsource then the text in D1 appears as the column heading in the Listbox,
but as each Item comes from filtered data, even though D1 is outside of the
filtered data range, D1 appears as the first Item in the Listbox.

Mike Milligan posted a similar question back in October this year (I think!)
under the title "Adding Headers To A Listbox"

All help on this gratefully appreciated.

Thanks

John



All times are GMT +1. The time now is 12:20 AM.

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