Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Mar 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Header in ListBox (Excel 2003)

    Hi,

    How do I set the header text for individual columns in a combo? It's the squares on top of the dropdown list.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Header in ListBox (Excel 2003)

    I assume that you mean a list box (as mentioned in the subject) or combo box (as mentioned in the body of the post) on a worksheet, created from the Control Toolbox, or on a userform created in the Visual Basic Editor.

    You can only have column headings if the list box or combo box is populated from a range on a worksheet, through its ListFillRange property (for controls on a worksheet) or RowSource property (for controls on a userform). If the ColumnHeads property is set to True, the row immediately above the ListFillRange/RowSource will be used as column headings.

    Example: you have a list box or combo box with 2 columns. ColumnHeads is set to True, and the ListFillRange / RowSource property is set to A5:B10. Cells A4:B4 will be used as column headings.

  3. #3
    Lounger
    Join Date
    Mar 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Header in ListBox (Excel 2003)

    OK - thanx' - what I ment was the list-box-part of a combo (a combo is by def. a text/listbox ctrl.).

    I don't use the ListFillRange prop. but instead AddItem/List::

    Do While Not g_rsMyResearchTemplates.EOF
    strItem = g_rsMyResearchTemplates.Fields(0)
    cbReportType.AddItem strItem
    strItem = g_rsMyResearchTemplates.Fields(5)
    cbReportType.List(iId, 1) = strItem
    strItem = g_rsMyResearchTemplates.Fields(1)
    cbReportType.List(iId, 2) = strItem
    iId = iId + 1
    g_rsMyResearchTemplates.MoveNext
    Loop

    And I looked for a cbReportType.SetHeader("col 1| col 2| col 3") etc. But such don't exist.

    Now, I expect that I have to use a header-only-fillrange? Silly that one have to work around it like that...

    Thanx' again!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Header in ListBox (Excel 2003)

    As I mentioned in my first reply, the only way to get column headers is to populate the combo box from a worksheet range. You can't combine that with AddItem - you get an error message if you try to add items to a combo box that has a non-blank RowSource. You'd have to fill a worksheet range from your recordset, either by looping through it, or by using the CopyFromRecordset method, and set the RowSource property of the combo box.

    Welcome to the Lounge, by the way!

  5. #5
    Lounger
    Join Date
    Mar 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Header in ListBox (Excel 2003)

    OK - and: arghhhh!!!

    Silly thing! I hate restrictions like that.

    This is a very helpfull and quick responding forum btw.

Posting Permissions

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