+ Reply to Thread
Results 1 to 16 of 16

ListBox help

  1. #1
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    ListBox help

    Hi all

    Could someone please help or provide some direction for me please as I’m a little stumped?

    I'm looking to add a listbox (or similar) to my userform which shows inputs held within Columns in a sheet.

    The listbox needs to show 5 columns and then the individual columns need to show ranges held in sheet ranges for example Column 1 - "B15:B64", Column 2 - "C15:C64", etc

    It’s not entirely clear how to go about this within the properties section

    Thanks for looking

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: ListBox help

    This will populate your listbox as requested (assuming listbox is named Listbox1). Note the placement of the code in the UserForm_Initialize event

    Please Login or Register  to view this content.

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

    Re: ListBox help

    Here's another method.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    Thanks for the qwick response.

    It works but it puts all the info in the first column of the Listbox, I was looking for something that would have 5 columns from left to right.

    Quote Originally Posted by stnkynts View Post
    This will populate your listbox as requested (assuming listbox is named Listbox1). Note the placement of the code in the UserForm_Initialize event

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: ListBox help

    Set for non-contiguous rows

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    Your a star!

    Thank you very much for your help.

    I'm just trying to format the range, however it does not like it.

    Any suggestions?

    Thanks again

    Please Login or Register  to view this content.
    Quote Originally Posted by stnkynts View Post
    Set for non-contiguous rows

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: ListBox help

    Do you mean like this?

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    Thanks

    It just debugs on this now

    Please Login or Register  to view this content.

    Quote Originally Posted by stnkynts View Post
    Do you mean like this?

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: ListBox help

    Submit the code as a whole for what you are trying to do. Submitting a copy of your worksheet with any sensitive information removed will be helpful.

  10. #10
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    Thanks for sticking with me on this.

    Unfortunately the userform and the code is a bit of a monster with loads of sensitive info. If I took it all out it would crash at every opportunity

    The range of cells that I am looking to format are numbers with two decimal points

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

    Re: ListBox help

    Do you want to display both columns formatted as they are on the worksheet?
    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: ListBox help

    Hopefully Norie's solution works for you because I am at an impass. I am not able to understand the scenario that you are dealing with and therefore am not able to answer your question.

  13. #13
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    I greatly appreciate your help so far on this. Its works 99%. Its just the formatting issue on the last two columns.

    Would it have anything to do on how the array is set up being a "xlCellTypeConstants" I have try the "xlCellTypeAllFormatConditions" but it liked this less.

    Quote Originally Posted by stnkynts View Post
    Hopefully Norie's solution works for you because I am at an impass. I am not able to understand the scenario that you are dealing with and therefore am not able to answer your question.

  14. #14
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    Thanks for this Norie

    This does allow me to change the format who I want, however how would I set this up to work in the same way as stnkynts is designed?

    I would need to have four columns within the list box with different ranges

    Thanks again

    Quote Originally Posted by Norie View Post
    Do you want to display both columns formatted as they are on the worksheet?
    Please Login or Register  to view this content.

  15. #15
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: ListBox help

    Did you try just changing this line in stnkynts code:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  16. #16
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Bournemouth
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: ListBox help

    romperstomper your a legend!

    Thank for coming to my rescue. I cant belive I didn't try that! Thats why i'm a novice!

    Quote Originally Posted by romperstomper View Post
    Did you try just changing this line in stnkynts code:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.

+ 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. Having problems populating a multicolumn listbox changing Listbox column with a loop.
    By Aristizabal95 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2013, 12:41 PM
  2. userform listbox
    By tsiguy96 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-14-2013, 11:09 PM
  3. [SOLVED] Indexing proper range in listbox depending on selection in previous listbox
    By bloodmeat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2013, 02:31 PM
  4. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  5. Replies: 12
    Last Post: 08-28-2012, 07:09 AM

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