+ Reply to Thread
Results 1 to 6 of 6

How to add Values to ListBox.ColumnHeads

  1. #1
    Registered User
    Join Date
    04-25-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    91

    How to add Values to ListBox.ColumnHeads

    Hello All,

    I really thought this was going to be easy but I am surprised to find that I'm racking my brain and there doesn't seems to be any solutions online - at least not what I have been able to find.

    How can I add the the values in row 1 to the headers row in the image below (into the empty boxes)?

    Image1.JPG

    My code is below.

    Please Login or Register  to view this content.
    I am currently using a range to add the values to the listbox but Ideally I want to just have some function to add labels.
    i.e.
    Please Login or Register  to view this content.
    But i realize that is will yield the same result I am getting - meaning, the use of "Me.ListBox1.List(0,0)" will add to row 1 and not the header column!

    I want to say that there has to be some function like:

    Please Login or Register  to view this content.
    for example, but I haven't found anything like this. AND, I guess I don't know what the ".ColumnHeads" functionality is used for if the cells will be empty - seems useless.

    I have tested using the source data in the worksheet as a Table and then the column headers are added correctly, but I have found in the past that userforms interacting with Tables can bog down the program and cause problems, so I would rather not go that route.

    Any help would be greatly appreciated!

    Thanks,

    Jason

  2. #2
    Registered User
    Join Date
    11-19-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    2016
    Posts
    57

    Re: How to add Values to ListBox.ColumnHeads

    set ColumnHeads to True and RowSource to start from row immediately below the headers row

  3. #3
    Registered User
    Join Date
    04-25-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: How to add Values to ListBox.ColumnHeads

    Sorry, I could not get that to work. But, I really don't want to use the workbook to provide the source data. Any way to add the header labels as I mentioned in my post?

    Thanks for your time, dOOb.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to add Values to ListBox.ColumnHeads

    herbie226

    The only way to add 'real' column headers is to populate the listbox using the RowSource property and setting ColumnHeads to True.

    There are ways you could add your own 'headers', for example you could add a set of labels above the listbox.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    11-19-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    2016
    Posts
    57

    Re: How to add Values to ListBox.ColumnHeads

    Assuming your data is in range A1:D4 where A1:D1 are headers and your ListBox has 4 columns, then to display these headers in your ListBox the way you want, the RowSource property of the ListBox should point to range "A2:D4" and the ColumnHeads property should be set to True.

    That grid at the very top of your ListBox gets populated with headers only if you are are populating your ListBox from range/table on worksheet. It does not work if you are filling your ListBox in from array or adding items to it one by one.

    Possible workarounds:
    1. Collect your ListBox items in a worksheet, edit headers if needed, then load the ListBox from worksheet.
    2. Collect your ListBox items in array, when ready, dump the array into worksheet, adjust headers if needed and load the ListBox from worksheet.
    3. On UserForm, add Labels/TextBoxes above ListBox.
    4. On UserForm, add separate ListBox above the existing one and load it with headers from worksheet.
    Last edited by dOOb; 04-25-2018 at 05:27 AM.

  6. #6
    Registered User
    Join Date
    04-25-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: How to add Values to ListBox.ColumnHeads

    Thank you, dOOb and Norie.

    Really wished there was another way but at least this clears everything up for me. I am very appreciative for your time and effort.

    Jason

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Show unique values in listbox and activate related cell if i select value in Listbox
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2018, 06:54 AM
  2. Columnheads does not display in listbox!
    By hoabattuvn_tt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2015, 07:07 AM
  3. [SOLVED] How do I populate a listbox with a list excluding values found in another listbox?
    By Hokiefan00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2014, 01:47 PM
  4. How to use ColumnHeads in a ListBox?
    By aspicuelta in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-13-2010, 01:53 PM
  5. userform listbox columnheads
    By borg in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-02-2006, 10:55 AM
  6. How to add data to ColumnHeads of Listbox
    By lehainam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2005, 08:05 AM
  7. VBA ColumnHeads Property for ComboBox
    By VBA Dabbler in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2005, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1