Title heading in Listbox1

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top