+ Reply to Thread
Results 1 to 8 of 8

Naming a range for a listbox

  1. #1
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Naming a range for a listbox

    I am trying to use the ColumnHeads feature in the listbox. The only issue I have is I have always used the .Add Item method.

    If all my data is on sheet (Data), how do I name a range thru code to fill the listbox property so I can set the ColumnHeads to true.

    Row 1 is a Header Row
    A thru E have data
    Last row may vary

    Thanks for any help or feedback,

    Josh

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Naming a range for a listbox

    Hello Josh,

    Here is an example of sizing the range before the UserForm is displayed.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Re: Naming a range for a listbox

    Hi Leith,

    Thank you for the response.

    I am getting an error with LastRow... Saying it needs an object ???

    I tried... Dim LastRow as Long but that didn't work.

    Josh

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Naming a range for a listbox

    Declare LastRow as a Range
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Re: Naming a range for a listbox

    thanks Roy... I am able to get it to work....

    The only problem is it seems to be stopping the range on row 11

    I have used a message box to show what the range and it is showing A2:F10 in both of the instances below.... do you know where it is being caught up on row 11?

    Here is the full code I am using to load a listbox with a range so I can use the column heads

    HTML Code: 
    Thanks and appreciate the help...

    Josh

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Naming a range for a listbox

    Looks like you have changed the Resize part
    Please Login or Register  to view this content.
    I think you need to attach the workbook

  7. #7
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Re: Naming a range for a listbox

    I kept Leith's part of the code the same accept for the A1 to E1, I changed to A1:F1....

    If you look at the first part of the code, this was always separate... this basically sends the filtered data I need to the sheet Campaign Filter.

    Then from Campaign Filter, I want to name the range so I can load the listbox and use the column heads.

    Under the comment 'Set Range for listbox is the identical code accept for the change above of adding one column....

    For some reason it sets the range to A2:F11 of campaign filter for the listbox even though there are more rows

    Hope that clarifies,

    Josh

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Naming a range for a listbox

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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