+ Reply to Thread
Results 1 to 39 of 39

Creating unique sorted list from dynamic table - Formula Solution Still Required

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Creating unique sorted list from dynamic table - Formula Solution Still Required

    MOD EDIT: The OP has a VBA solution below, but is also looking for a formula alternative.

    Hi,

    i asked earlier about creating formula to get sorted and unique list here:

    https://www.excelforum.com/excel-gen...ml#post4955031

    Problem is that i have to create new separated column for this.

    What about VBA?

    Can we do it on the fly?

    I mean to get sorted and unique data validation list.

    The best option would be a function which would run when arrow down from data validation list is clicked

    Something like: check whata data source it is, and sort it and remove duplicates - in the end show results to the end user.

    IT is possible?

    Best,
    Jacek


    Edit: to have 2 solutions in one topic as AliGW said : i need here also second solution: have this done by formulas. Please help.
    Attached Files Attached Files
    Last edited by AliGW; 08-15-2018 at 01:37 AM. Reason: Moved to Formulas & Functions section for the second half of the issue.

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Creating unique sorted list from dynamic table

    I'm not sure what your sample workbook is meant to show.

    Can you show what you are trying to achieve with a full explanation?

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table

    Hi,

    as you can see here is a validation list from table.

    In validation list i have =

    Screenshot_49.png

    What i want to:

    Run macro when you select drop down list.
    Run macro which should show only unique list with sorted order (alphabetic or numbers).

    In data validation list i have:

    Please Login or Register  to view this content.
    i do not want to change it.

    Thank you for helping,
    Jacek
    Attached Files Attached Files

  4. #4
    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,907

    Re: Creating unique sorted list from dynamic table

    It is certainly possible but, as I said before, if the list might be longer than 255 characters as a comma separated list (including the commas), you'd still need a separate column for the data; or you'd have to use a control rather than data validation.
    Rory

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table

    rorya,

    thank you, yes you said this.

    I am interesting how to do it with 255 limit in one list and in separate column.

    Best,
    Jacek

  6. #6
    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,907

    Re: Creating unique sorted list from dynamic table

    Here is a function to get a unique list from a range:

    Please Login or Register  to view this content.
    That will return an array, which you can sort in numerous ways - e.g. a bubble sort:

    Please Login or Register  to view this content.
    Once you have the sorted array, you can either drop it into a range, or assign it to the Formula property of the data validation using Join to add the necessary comma delimiters.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    To a sheet module
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    wow thank you Guys,

    awesome!

    jindon - wow!
    I understand all without:

    Please Login or Register  to view this content.
    x is already arraylist here (Set x = .Clone).

    What is sort_2 property? How this is working?
    Are you creating new object "CaseInsensitiveComparer"? With opening brackets?

    Best,
    Jacek

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    It has Sort, Sort_2 & Sort_3 methods.
    Sort_2 & Sort_3 method accept CompareMode

    See the difference
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    Nice,

    so somehow you invoked here the method from here:

    Please Login or Register  to view this content.
    Thank you,
    you are brilliant.

    Best,
    Jacek

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    Hi,

    anyone with formula solution and sorting?

    (if it is possible for both numbers and text, but if not - text will be good ok).

    Best,
    Jacek

  12. #12
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    Anyone?

    (input 2 topics into one it is a not good idea - topic is not seen by users).

    Best,
    Jacek

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: Creating unique sorted list from dynamic table - Both Formula & VBA Solutions Required

    Stop complaining and be patient! I have explained the rules to you. This is ONE topic to which you want TWO solutions, not two different topics.

    I will now move the thread to the formulas and functions area for visibility.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  14. #14
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Hi,

    solution is here.

    https://www.get-digital-help.com/201...lues-in-excel/

    Best,
    Jacek

  15. #15
    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,907

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Since you have 2016, get and transform would be more efficient.

  16. #16
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    What do you mean rorya?

    Can you help with this?

    Best,
    Jacek

  17. #17
    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,907

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    I mean load the table into power query, select the column then sort and group it and output to a new table. Then all you need to do is refresh the query if the source data changes.

  18. #18
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Thank you,

    best,
    Jacek

  19. #19
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Hi,

    solution from post #14 is not working, i have to refresh the topic.

    Formula is only sorting values but they are still not unique.
    Can you help me with this?

    Best,
    Jacek

  20. #20
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Hi,

    anyone?

    Best,
    Jacek

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Define "not working".

  22. #22
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Hi,

    Formula is only sorting values but they are still not unique.
    best,
    Jacek

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Attach a workbook that shows the problem.

  24. #24
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Please find workbook attached.

    In sheet2 you can see formula which is sorting but getting all values, not unique.

    Best,
    Jacek

  25. #25
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Hi,

    Please help,
    Jacek

  26. #26
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Hi Guys,

    nobody can do it ?

    Best,
    Jacek

  27. #27
    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,907

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    If you can wait a bit, the new dynamic arrays will make this really easy! https://www.microsoft.com/en-us/micr...day-at-ignite/

  28. #28
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    wow, very nice!

    but i have to do this now rorya

    Best,
    Jacek

  29. #29
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Array formula in sheet 2, A2, coped down.

    =IFERROR(INDEX(List,MATCH(0,COUNTIF(List,"<"&List)+10^10*(List="")-SUM(COUNTIF(List,A$1:A1)),)),"")

    Your Named ranges both use OFFSET, which might cause performance issues on REALLY big sheets. is that likely to be an issue?
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  30. #30
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    hi Glenn,

    thank you very much!

    Yes, it can be an issue. How to avoid OFFSET within named ranges?

    Best,
    Jacek

  31. #31
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Ok Glenn,

    few questions.

    What count if is counting here?

    Please Login or Register  to view this content.
    What 0 means here? and why + 10 ?

    Please Login or Register  to view this content.
    what does it mean?

    Best,
    Jacek

  32. #32
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Replacement for the 2 NRs:

    =$A$2:INDEX($A$2:$A$12,SUMPRODUCT(--(LEN(Sheet1!$A$2:$A$12)>0)))

    and

    =Sheet1!$A$1:INDEX(Sheet1!$A$1:$A$100,COUNTA(Sheet1!$A$1:$A$100))

    see sheet. Adjust ranges as needed... but don't go daft and use 000s of rows if you don't need to.
    Attached Files Attached Files

  33. #33
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Correct file attached...
    Attached Files Attached Files

  34. #34
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    You got the phrasing wong...

    It was:

    +10^10*(List="")

    It was an added "extra" which you might not need. If your range contains blanks, this effectively removes them from consideration. If you range CAN NEVER contain blanks, then leave this phrase out and use:

    IFERROR(INDEX(List,MATCH(0,COUNTIF(List,"<"&List)-SUM(COUNTIF(List,A$1:A1)),)),"")

    array-entered.... instead.

  35. #35
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    thank you Glenn,

    Please Login or Register  to view this content.
    so how this is caculated?

    for example 10 * {0,4,6,1} ?

    and how this is working?

    Please Login or Register  to view this content.
    thank you for help,
    Best,
    Jacek

  36. #36
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    I changed one of the Named Ranges so that it would work if there are blanks in the data. No point in having a formula that works with blanks.... if the Named range doesn't.

    COUNTIF(List,"<"&List)+10^10*(List="")

    is responsible for sorting the list and removing blanks.

    COUNTIF(List,"<"&List)

    resolves to:{1;3;2;0;0;3}

    This is the number of values in the list that are alphabetically lower than each value.

    So, in this case:
    BB
    DD
    CC
    blank
    AA
    DD

    {1;3;2;0;0;3}There is one value lower than BB,
    {1;3;2;0;0;3} There are 3 values lower than DD
    {1;3;2;0;0;3} There are two values lower than DC....

    The lowest value (AA) and the blank both return zero. {1;3;2;0;0;3}

    To resolve this, +10^10*(List="") is used. This adds 10^10 (10 to the power of 10... 1 with 10 zeros after it) to all instances where the value in the named range is a blank. So... it resolves to:

    {1;3;2;10000000000;0;3}

    The MATCH function returns the row of the value = zero. the last phrase in the formula ensures that the next lowest alphabetical value becomes zero on the next line... and so on.
    Attached Files Attached Files

  37. #37
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    oo thank you,

    awesome explanation ! For people like me !

    Best Wishes,
    Jacek

  38. #38
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    one more thing Glenn,

    Please Login or Register  to view this content.
    how the SUMPRODUCT is working here? with "--" signs?

    This is summing all arrays so here "2" appears 5 times so we have 5 as sum product yes? {2;2;2;2;2;0;0;0;0;0;0}

    Best,
    Jacek

  39. #39
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Creating unique sorted list from dynamic table - Formula Solution Still Required

    Not quite. The formula looks for cells with length >0. It returns true or false. The -- converts true to 1 and false to 0 and SUMPRODUCT adds them up.

+ 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. [SOLVED] Sorted and unique validation list
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-23-2016, 05:20 PM
  2. Replies: 9
    Last Post: 02-26-2014, 04:17 PM
  3. Creating An Auto-sorted To Do List
    By ProfessorLyle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-29-2013, 03:39 PM
  4. Extract a sorted and ranked unique list of items
    By bruno_ in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-11-2013, 09:52 PM
  5. [SOLVED] Unique distinct alphabetically sorted list
    By atlant15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 10:03 AM
  6. Sorted List of all Unique strings
    By ElmerS in forum Excel General
    Replies: 2
    Last Post: 04-30-2009, 02:40 PM

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