+ Reply to Thread
Results 1 to 18 of 18

Directed Listbox Population

  1. #1
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Directed Listbox Population

    I have a Listbox that gets populated by a code which gets all the worksheet names in the workbook and puts in the Listbox. The code has entries to skip some sheets so they do not get put in the Listbox. Of what gets put in the listbox, they're in alphabetical order. I'd rather direct which pages are at the top of the list. The last two characters prior to a "-" is how I would need to choose the population algorithm. AAAAAATB-BBBBBBWT. I would say all of the TBs get populated first, followed by the WTs, then the KOs etc, and then anything else gets populated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    Attach a workbook that has all the sheets. Make sure to get rid of personal data, if there is any. Delete any data that is not needed to bring the attachment size down.
    In one of the sheets, have an example of the list as you would want it
    The inherent weakness of the liberal society: a too rosy view of humanity.

  3. #3
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    I built a small workbook. It has to look at the two characters before the dash. It needs to be dynamic as there's a dozen different names I didn't include. I don't know how to approach it, some kind of weighting system? 1-5, and the WTs are assigned to the 1 case, and TBs to the 2 case? I don't even know, it sounds complicated.

    Index
    Matters Not bottom of list
    Doesnt Matter bottom of list
    xxxxxxCX-xxxxxx61 After TB
    xxxxxxTB-xxxxxxWT second in lst
    xxxxxxTB-xxxxxxKO second in lst
    xxxxxxTB-xxxxxxAO second in lst
    xxxxxxWT-xxxxxxKO top of list
    xxxxxxWT-xxxxxxAV top of list
    xxxxxxAV-xxxxxx61 after TB
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    Put all your sheet names in a column, delete the names that you don't want and in the in the column beside this have the 2 characters from before the special character ("-") through a formula or by code. Sort on this and put list into listbox.

  5. #5
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    That doesn't sound very fun Joli. I'd rather find a programatical solution just for the knowledge of how to do it.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    If you want to do it a different way, google on Bubble Sorting. I don't know anything about that because I like to do it the easy way. See attached
    Attached Files Attached Files

  7. #7
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    Can you code it that it excludes the Worksheet names ending with MAP?
    Please Login or Register  to view this content.

  8. #8
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    I list sheets here that I do not want added into the Listbox right? Other than the MAP ending, I would like to programatically exclude the MAP worksheets, as there's a lot of them.
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    What else needs to be added/deleted after that?


    Add the two lines.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 05-16-2023 at 11:08 PM.

  10. #10
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    That didn't seem to work, the Map sheets are in the listbox. this is what a Map sheet looks like: xxxxxxWT-xxxxxxAV MAP


    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    You're mixing up Map and MAP.

    Put "Option Compare Text" as first line, like so
    Please Login or Register  to view this content.
    Maybe put this in the Index sheet module also.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 05-17-2023 at 01:44 AM.

  12. #12
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    What does the Option Compare Text do? What if I wanted to change the order to where TB is first, then WT, then KO?
    What is the correct code for integrating this into the above code where it hides the MAP worksheets?
    Please Login or Register  to view this content.
    Last edited by tome10; 05-17-2023 at 04:38 PM.

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    From "Excel Help"
    Option Compare Text results in string comparisons based on a case-insensitive text sort order determined by your system's locale.

    TB first, WT second, KO third, CX fourth, AV fifth and all others at the end.
    Somebody hopefully comes up with a more elegant solution.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 05-18-2023 at 03:26 PM. Reason: add forgotten code tags

  14. #14
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    I can't seem to figure out where to put this in the above code. I keep getting end if without block if. Thanks for the help with the case statement, it works great.

    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Directed Listbox Population

    What do you want to do?
    You asked to list all sheets except 3 and where "MAP" is part of the name.
    So what does hiding sheets have to do with that?

  16. #16
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    considering this post is solved, I'll create a new post. but, the Map sheets get called by a control in their parent sheets, so they do not need to be in the listbox (Solved), or visible in the workbook until called.

  17. #17
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    I didn't get any help with the other thread, I need to do all this from the worksheet activate, so I'm back here. I need to make sure the * MAP worksheets are hidden, and hide all sheets with an index greater than 7.

    Please Login or Register  to view this content.
    Last edited by tome10; 05-20-2023 at 06:43 PM.

  18. #18
    Banned User!
    Join Date
    08-10-2011
    Location
    Little Rock Arkansas
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    101

    Re: Directed Listbox Population

    Removed due to old and Solved Post
    Last edited by tome10; 07-25-2024 at 01:52 PM.

+ 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. Listbox on userform population and modification
    By Lsxtrkiller in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2017, 03:29 PM
  2. [SOLVED] Assistance with ListBox row source population via textbox Value
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2016, 06:20 AM
  3. [SOLVED] Vba assistance with coding for ListBox population from textBoxes
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2016, 06:26 AM
  4. Listbox and textbox population
    By molesy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2014, 06:40 AM
  5. Complex ListBox Population
    By abhishekchak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2012, 06:28 AM
  6. ListBox Population issue
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2009, 06:19 PM
  7. Multiple Listbox? Population
    By Pete in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2005, 11:06 AM

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