Link to home
Start Free TrialLog in
Avatar of Phil_Consultant
Phil_ConsultantFlag for United States of America

asked on

VBA: How to Populate Column Headers in Multicolumn List Box When Source is an Array?

Hello,

I'm using Excel 2013 and have a user form with a multicolumn list box. Because of filtering from controls (text box, combo box, etc) and other reasons I've chosen to populate the list box with an array rather than via row source. At this time, the row source vs array is non-negotiable. The multicolumn list box works quite well except that the row headers are blank.

My research reveals that if you provide a row source then Excel will identify the column headers but if your source is from an array then there is no way to put column headers in. I refuse to accept that and figure someone out there knows of some quirky workaround. Sometimes things are accomplished with unique tricks and hopefully someone here can think of something. I've looked throughout the web and haven't found any concrete solutions without binding data to a range... at which point you might as well go with row source.

Any thoughts on how to populate the column headers while using the array source? Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Phil_Consultant

ASKER

Hi Norie,

I've considered your idea but one piece of information I accidentally left out is that the multicolumn list box has many columns thus scroll bars (both top/bottom and left/right). My understanding is that if I was to scroll the data left/right the columns wouldn't align. Thanks for the suggestion.
Avatar of Norie
Norie

You probably could do something to keep the headers aligned with the columns when scrolling but I've a feeling it would probably involve using Windows API.

Have you considered using a ListView control instead of a Listbox?