Solved

Excel listbox with headers

Posted on 2014-12-19
5
104 Views
Last Modified: 2015-01-05
Hi All,

Excel 2007

I have a listbox on a userform that I'm populating by looping through a recordset.

Because this is excel and not access, I cannot set the rowsource of the listbox to anything other than a range, and so I'm currently not seeing any headers.

Does anyone know of a way around this programmatically? I'm not particularly enthusiastic about creating a temporary area / range for my recordset just so that it can be a rowsource.

Thanks

Rgds
0
Comment
Question by:James Elliott
5 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 250 total points
ID: 40509328
You can only have proper headers if you use a range. Beyond that you have to fudge it using either the first row of the list as headers (with code to prevent selecting it) or use labels or another listbox above the listbox to present the headers.
0
 
LVL 33

Assisted Solution

by:Norie
Norie earned 250 total points
ID: 40509333
Use a small, one row listbox with the same column widths as the main listbox, populate it with the headers and place it just above the main listbox.
0
 
LVL 18

Expert Comment

by:krishnakrkc
ID: 40512396
You can write the recordset data directly into cells and refer the range into the listbox rowsource. No loop needed.

Kris
0
 
LVL 18

Expert Comment

by:krishnakrkc
ID: 40512397
Please ignore my above post, I haven't fully read your question :(

Kris
0
 
LVL 12

Author Closing Comment

by:James Elliott
ID: 40531581
Sorry for the delay.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question