Solved

Excel listbox with headers

Posted on 2014-12-19
5
106 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 34

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

695 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