+ Reply to Thread
Results 1 to 13 of 13

Impossible to fill the header of a ListBox that is in a Sheet.

  1. #1
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Impossible to fill the header of a ListBox that is in a Sheet.

    Hello,
    I have created a ListBox (ActiveX) on a worksheet (and not in a UserForm).
    I try to fill this list with VBA by calling this function :

    Please Login or Register  to view this content.
    It fills the list entirely but it misses the header line. Actually, the titles appear in the second line, and the header line remains empty !
    ( despite my .ColumnHeads = True)

    What is strange, it is that when I do this in a UserForm (with a 'regular' ListBox), the result is correct.
    But definitely, when I do it in a ControlX listBox located on a sheet (and not in a UserForm), it fails...

    Any idea please ?
    Thanks anyway...Pierre

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    ActiveX controls on a worksheet are not quite the same as the controls on a UserForm.

    Please Login or Register  to view this content.
    has an effect only when you are populating the list using the ListFillRange attribute on the ActiveX version on your worksheet, or RowSource on the UserForm version.

    There may be differences between how you have configured the two list boxes that make them behave differently. It's not possible to verify without your file. I also cannot run the code above without your file because of the data references and calls to other Functions.

    Consider attaching a sample file for review. See yellow banner at the top of the page.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    Thank you for your answer. You are right, my lines were too specific.

    Here is a an Excel Workbook with a sheet 'Feuil1' containing a ControlX ListBox named 'ListBox1'.
    (provided here).

    A Click on button 'Bouton3' populates the ListBox, and the same problem occurs (header line is empty).

    More than this, I realize that I am unable to get the selected value back (ListBox1_Click() does not work)

    Thanks again, Pierre

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    The last point (getting the value selected back) is solved. I do this in the module :

    Please Login or Register  to view this content.
    And this in the "Feuil1" code part:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    You can only use the column headers if you link the control to a range. You'd have to copy your data somewhere and link to that, or mess about with labels positioned above the listbox.
    Rory

  6. #6
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    thanks... I go for making a range and link it to the LB...

  7. #7
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    Sorry but I keep on failing, even with a Range (or a Table).

    I give you my attempt (TestLBCotrolXRange.xlsm)

    I build the range in a "Fake" sheet (as well as a table based on this range).

    Then I try to link this range (or the table) to the listbox... but it does not work

    Thanks again...
    Attached Files Attached Files

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    You need to include the sheet name in the address string that you pass to the listfillrange.

  9. #9
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    Sorry but I don't see which line :
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    No:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    Thank you, that helps a lot, but still, I cannot have my header values in the header line of the listbox, these titles appear below, in the list itself.LB.png

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    The range you use should not include the header row. The control will use the row above automatically.

  13. #13
    Registered User
    Join Date
    12-12-2023
    Location
    France,
    MS-Off Ver
    Professional Plus 2016
    Posts
    24

    Re: Impossible to fill the header of a ListBox that is in a Sheet.

    That's perfect ! Many thanks to you
    Perfect.png

+ 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. Need VBA Code to fill Database through Userform to sheet under header
    By henrybrothers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2023, 06:04 PM
  2. [SOLVED] Content control editing impossible in header afetr enforcing protection
    By Pepe Le Mokko in forum Word Formatting & General
    Replies: 15
    Last Post: 12-19-2019, 04:47 AM
  3. VBA to re-name every first sheet and fill column header from P To U
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2016, 03:40 AM
  4. [SOLVED] need vba to fill values under particular header from master sheet
    By julielara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-26-2016, 06:16 AM
  5. [SOLVED] Fill a listbox from a non active sheet with option button
    By molesy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2014, 07:44 AM
  6. Fill Listbox with 2 sheet columns.
    By RayJay01 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-28-2013, 05:08 AM
  7. VBA to choose template, fill it in and then save workbook - impossible??????
    By dm@stams in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2012, 06:37 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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1