+ Reply to Thread
Results 1 to 18 of 18

Formula to list all matches excluding duplicates

  1. #1
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Formula to list all matches excluding duplicates

    Hello

    Im looking for a clever way to combine lists and find each unique value for a specific lookup. I tried to simplify it by the following example with numbers and colors:

    Different lists with some uniques (ie 4 only represented one time with the value Green), some duplicates (ie 2 represented several times with the value Red), and some with different values for the same lookup (ie 1 represented with both Blue, Green and Red):
    25-11-2017 10-20-31.jpg

    I need a formula to list this in a combined cell like below, where it will only list the duplicate matches once and separate different matching values with comma (or something similar):
    25-11-2017 10-28-38.jpg

    I attached a sheet with the example above.

    I might add that I have several huge lists (15.000 lines each), so if possible at all, a performance friendly solution would be preferable.

    Any help would be highly appreciated
    Attached Files Attached Files

  2. #2
    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,099

    Re: Formula to list all matches excluding duplicates

    You're probably best to use a UDF for that.

    Please Login or Register  to view this content.
    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)


    Then use this array formula:

    =concatall(IF($B$3:$H$5=B8,$C$3:$I$5,""),", ",TRUE)

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...

    enable macros on opening...
    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

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Formula to list all matches excluding duplicates

    what is the maximum number of possible lists.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Formula to list all matches excluding duplicates

    Try with a helper column.

    F8
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...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.

    Copy across K column and down.

    C8
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Check the attached file.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  5. #5
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Thanks so much!

    I will try to experiment with the suggested solutions.

    @nflsales: The lists are dynamic and in different sheets, but my guess is that 5 lists are maximum.

  6. #6
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    @Glenn Kennedy
    Im trying to work with your solution, but can this be used if the lists were in other sheets, like in the example I uploaded below?
    Attached Files Attached Files

  7. #7
    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,099

    Re: Formula to list all matches excluding duplicates

    No. It won't work. That was a very significant fact that you left out of your original post!!

    However, if you are OK with having the results in separate cells, this array formula will work.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Hopefully you can see that it's made up of separate bits that can be expanded easily to cope with 5 lists.

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Yeah I am very sorry, I should not have left out that fact, but I just tried to keep it simple, as the setup in my actual file is quite complicated. But I think I can work with your last solution

    Really appreciate the help!

  9. #9
    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,099

    Re: Formula to list all matches excluding duplicates

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  10. #10
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Turns out I could actually use both solutions from you Glenn for different purposes, so your first effort was not wasted

    But I would like to use the second solution several times throughout the columns, listing different columns from the different sheets. For instance a Color3 listing after the Color1 listing.

    The problem I run into here, is the $B3:F3 part in the COUNTIF($B3:F3, List1!$D$2:$D$4)=0), as it should actually not include C-F columns for the second listing.

    I attached a sheet to illustrate this and I added an empty column in the lists to point out that there could be several other columns with data in between.

    Any way to solve this?

    Again thanks so much for all the help - im learning so much
    Attached Files Attached Files

  11. #11
    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,099

    Re: Formula to list all matches excluding duplicates

    Just introduce a blank column (to allow the formula to have a starting point - one which has no potentially interfering data in it) and adjust the ranges as shown.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    That will work - your help is highly appreciated!

  13. #13
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Hello again Glenn

    The first ConcatAll function you came up with is amazing - I use it for a bunch of things. One problem though - if any of the lists contains an error (ie #I/T) everything will fail. I tried messing around with some <>"#I/T" in the formula, but without success. Any workaround for this?

    I attached a sheet to show what I mean.
    Attached Files Attached Files

  14. #14
    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,099

    Re: Formula to list all matches excluding duplicates

    Remove the error in the first place.

    IFERROR(VLOOKUP(B13,B8:B11,1,FALSE),"")

  15. #15
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Yeah, but my different lists might contain errors for several reasons that I rather not remove cause they are validating on something else.

    But I just figured it out. Might not be the be way but this works (concating 4 columns for each row in this case and also removing 0 for empty cells):
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Thanks again

  16. #16
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Hello again Glenn

    It seems that my solution for making it work with errors does not work in all cases, but I will try to mess a bit more with a sustainable workaround for that.

    But I have noticed that while running other scripts, that does not involve any Concatall formula, it steps into into the Concatall formula and runs it through. For instance this sometimes happen when I run a sub that clears all contents in the some sheets, even sheets that does not contain any Concatall formulas. Can you tell me what exactly triggers the Concatall formula? Is it when it comes across any cells that previously had a Concatall formula or when it comes across cells with "||" or something else?

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

    Re: Formula to list all matches excluding duplicates

    Can you post a sheet?

  18. #18
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Formula to list all matches excluding duplicates

    Attached a testsheet with some stuff from my main sheet.

    Code is messy, will clean it up at some point, so please disregard that

    But what you will notice, is that when running the sub Rolldata from Main module it will run into the Concatall, when it reaches the line below under Case Is = "Hent data"
    Please Login or Register  to view this content.
    I have a sheet with some Concatall formulas in, called concattest, but im not touching that sheet at all while running though Rolldata. Deleting the concattest sheet will stop it from running through it though, so im quite confused by what triggers Concatall.

    I hope you get what I mean, if not I will post some screenshots to make it more clear
    Attached Files Attached Files
    Last edited by Imbizile; 12-09-2017 at 09:38 AM.

+ 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. Count from a text list, excluding duplicates, with multiple criteria
    By Ecervantes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-18-2017, 10:42 PM
  2. Need to average data excluding blanks that matches 2 vlookups.
    By jdiegelmann in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-13-2017, 08:56 AM
  3. [SOLVED] Formula to search for matches, duplicates and new values between 2 columns
    By randomkiwi in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-19-2016, 04:53 PM
  4. [SOLVED] Return list of products excluding duplicates
    By Chanley24 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-22-2013, 02:21 AM
  5. [SOLVED] Function To Build A List For A Drop Down, Excluding Blanks And Non-Matches.
    By GEANZ in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-02-2013, 11:35 PM
  6. Create New Count List Excluding Duplicates
    By Scudder93 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2012, 10:33 AM
  7. [SOLVED] Formula to count cells between dates excluding duplicates
    By Vegs in forum Excel General
    Replies: 11
    Last Post: 07-05-2006, 02:15 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