Results 1 to 3 of 3

Thread: How can I add a Listbox header using VBA in Excel

  1. #1
    Join Date
    Oct 2011
    Posts
    96

    How can I add a Listbox header using VBA in Excel

    I have Column A to BH in my excel sheet. I want to display column A, B ,C,E, G and BH in a userform listbox. I've managed to use VBA to add selected column data into the listbox. My problem is I have no idea how to create a list header on top of the list box. I try using the additem but it doesn't work. My listbox has horizontal scroll bar as the list is too long so I can't use label to create the list header name.

  2. #2
    Join Date
    Aug 2011
    Posts
    540

    Re: How can I add a Listbox header using VBA in Excel

    AFAIK you can't, you can only get headers if you bind the listbox to a range.
    In the ListBox,
    • set the ColumnCount property to number of columns,
    • set ColumnHeads to True,
    • set RowSource to the range of cells >>below >> the column headers text

    The cells above this RowSource range will be used as column headers. You can set the rowsource in VBA
    With Me.ListBox1
    .RowSource = Range("A2:A5").Address
    End With

  3. #3
    Join Date
    Aug 2011
    Posts
    695

    Re: How can I add a Listbox header using VBA in Excel

    You can do the same using the normal cycles, or with a simple assignment or by transposing the matrix or range, ie, reversing the original order of data by making the columns instead of rows and vice verse. In some cases you can also use the column headings (ColumnHeads).

Similar Threads

  1. Connect USB 3.0 front case panel header to motherboard w/o a header?
    By Dogs-Day-Out in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 14-04-2012, 07:02 PM
  2. I need help to lock pivot table header in Microsoft Excel
    By cupid! in forum MS Office Support
    Replies: 2
    Last Post: 21-02-2012, 05:01 PM
  3. C# Listbox control
    By abhinavm in forum Software Development
    Replies: 2
    Last Post: 07-08-2009, 11:01 PM
  4. IIS7: Add expires header or cache-control header
    By quota in forum Software Development
    Replies: 3
    Last Post: 06-06-2009, 07:45 PM
  5. How to add Header and Footer in Excel 2007
    By michaels in forum Windows Software
    Replies: 3
    Last Post: 05-05-2009, 06:31 PM

Tags for this Thread

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
  •  
Page generated in 1,715,763,490.12692 seconds with 17 queries