Solved

Excel listbox with headers

Posted on 2014-12-19
5
100 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Please ignore my above post, I haven't fully read your question :(

Kris
0
 
LVL 12

Author Closing Comment

by:James Elliott
Comment Utility
Sorry for the delay.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now