+ Reply to Thread
Results 1 to 10 of 10

Create sorted list based on longer, unsorted source

  1. #1
    Registered User
    Join Date
    01-29-2013
    Location
    The Netherlands
    MS-Off Ver
    2016 x64
    Posts
    48

    Create sorted list based on longer, unsorted source

    Hi,

    I have a workbook (simple version attached) in which I have a source worksheet that contains an unsorted list of values (approx 400 lines). In a second worksheet I want to use a list (data validation) that only contains a selection of the values in the source worksheet.

    the workbook:
    3 worksheets: Source (1), Lists (2) and Second (3)
    Source: source list and some extra working columns to help me determine which values I want to have in the list. The code to update the list is only triggered when there is a change in the source list.
    List: hidden ws that is used to maken the new (sorted) list
    Second: any other ws in which I want to use the sorted list as a dropdown menu.

    my question:
    is there a way to make the code more efficient?
    how can I sort the new list and have the duplicates and blanks removed?

    thanks

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Create sorted list based on longer, unsorted source

    Please Login or Register  to view this content.
    This part of your code is re-triggering the Workbook_Deactivate event procedure hundreds of times causing CreateTaskList1 to be called each time. Adding the Application.EnableEvents = False prevents that.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    01-29-2013
    Location
    The Netherlands
    MS-Off Ver
    2016 x64
    Posts
    48

    Re: Create sorted list based on longer, unsorted source

    Hi AlphaFrog,
    I see the difference. Thanks.
    so that leaves the sorting etc issue...
    Daniel

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,565

    Re: Create sorted list based on longer, unsorted source

    Just a thought.
    Use the BudgetTaskList column on the 'List' sheet as a helper. The actual list, Task_work_List_2, could then be populated using*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Denotes an array entered formula which is confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Note that I did not link the table on the 'Second' sheet to the new column on the 'List' sheet.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    01-29-2013
    Location
    The Netherlands
    MS-Off Ver
    2016 x64
    Posts
    48

    Re: Create sorted list based on longer, unsorted source

    Hi JeteMc, this is briliant :-)
    I changed the formula a little bit so that I use the column in the "source" sheet instead of the list in the "list" worksheet. Works more direct and removes a copy step in the macro :-)
    I cannot get rid of the blanks at the end, but these are at the end of the llist so I do not mind.

    Any idea if technically is possible to also have a dropdown field like in the "second" worksheet that not shows 1 column (with the codes only), but shows the descriptions as well..
    I know this is possible in a dropdownbox with macros, but I need this is a list for every line...

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,565

    Re: Create sorted list based on longer, unsorted source

    The array entered formula in column E on the list sheet has been modified to read:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A list that combines tasks and descriptions, is produced in column H on the Lists sheet, using: =E4&" "&F4
    The Named Range "BudgetTaskList" has been modified so that it refers to column H
    If you select a drop down in column A on the Second sheet you'll see that it displays both tasks and descriptions.
    Let us know if you have any questions.

  7. #7
    Registered User
    Join Date
    01-29-2013
    Location
    The Netherlands
    MS-Off Ver
    2016 x64
    Posts
    48

    Re: Create sorted list based on longer, unsorted source

    Hi JeteMc,
    I was thinking of having the dropdownlist shoing 2 columns, only when selecting a line only the value of the first column is entered in that field. See attachment.
    I know this works on a form, but I do not know how to get this in a list/table.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,565

    Re: Create sorted list based on longer, unsorted source

    I have let this sit for a few days in hopes that someone else with more experience regarding drop downs would pick this up. I am not aware of a way to do what you are asking. I wonder, however, why you would want to do this. It occurs to me that the reason might be that people would recognize the descriptions but not the tasks. If that is the case would it be acceptable to put the drop down in column F, linked to the list of descriptions in table 1, then auto fill column A using Index/Match to display the Tasks?
    Let us know if you have any questions/comments.

  9. #9
    Registered User
    Join Date
    01-29-2013
    Location
    The Netherlands
    MS-Off Ver
    2016 x64
    Posts
    48

    Re: Create sorted list based on longer, unsorted source

    The reason I need this is that the code itself does not mean much to the user. When the list of codes is long it would be more convenient to also see (a part of) the description for that code.

    I have given it some thought too....

    When I create list with the concatenated values of column 1 and 2, then I have both in the named range used in the datavalidation.
    However, then I would require logicthat writes just the code to that cell and not the code+description

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,565

    Re: Create sorted list based on longer, unsorted source

    Quote Originally Posted by kammend View Post
    The reason I need this is that the code itself does not mean much to the user.
    That is why I feel that using the descriptions as the drop down and indexing the tasks is the better option.
    If you look at the attached file you'll see that a new named range is added which refers to the descriptions in table 1.
    Data validation is applied to the descriptions column in table 2.
    The task column is table 2 is populated using: =IFERROR(INDEX(Table1[Tasks2],MATCH([@Description],Table1[Description],0)),"")
    Let us know if you have any questions.

+ 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. Depenedent dropdown list to work even if source data is unsorted
    By kosherboy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-31-2015, 09:55 AM
  2. Create List based on TODAY() and IF value is < X on source table
    By Flyinace2000 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-12-2012, 05:40 AM
  3. macro to generate sorted table from unsorted list?
    By JGCA in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2009, 11:36 AM
  4. Replies: 4
    Last Post: 09-04-2008, 09:51 AM
  5. [SOLVED] how to create a sorted summary list of counted species
    By pak in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-20-2006, 07:15 PM
  6. Replies: 1
    Last Post: 04-20-2006, 06:21 PM
  7. [SOLVED] How to select sorted data listed under an unsorted grouping?
    By Joe R. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2005, 10:20 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