+ Reply to Thread
Results 1 to 4 of 4

How to remove duplicates within duplication sets based on criteria?

  1. #1
    Registered User
    Join Date
    11-05-2016
    Location
    Texas, United States
    MS-Off Ver
    MS Office for Mac; 2016
    Posts
    2

    How to remove duplicates within duplication sets based on criteria?

    I want to know how to filter the duplicate sets in the "m/z" column [highlighted yellow so that I can easily differentiate between the different duplication sets] based on:

    Keep the row within the duplication set if (TO BE FOLLOWED IN CHRONOLOGICAL ORDER):
    1.) N/O value <= 2 (denoted in green)
    2.) (N+S)/O value <= 1 (also denoted in green)
    3.) keep the row with the highest H/C value that is <= 2.25

    What I need to do with these tests (or rules) is use them to compare each duplicate row within the duplication set to find one "Last man standing."

    For example: look at duplication set of row 35, 36, and 37. All three pass the N/O test, so all three of the rows advance to the 2nd test. Now, row 35 and 36 fail the 2nd test due to being bigger than 1, and row 37 passes because it is <= 1; meaning that row 35 & 36 will get deleted and row 37 will stay as the "last man standing."

    You see, I can't just filter every row that fails a test within the entire workbook because some rows that fail a test may still be the "winner" because it passed the most tests compared to the others within its duplication set.

    For Example: look at row 18, 19, and 20. Because row 18 failed the N/O test, it gets deleted. But, 19 and 20 pass so they both move on to the (N+S)/O test. Since row 19 failed the 2nd test and row 20 passed, that makes it the only row left, and therefore, it is declared the "winner" and stays as the "unique" duplicate. However, notice that row 20 failed the 3rd test with having a value greater than 2.25. This is ignored because row 20 beat row 18 and 19 before it could "compete" in the 3rd test.

    So if I were to just delete all of the rows that failed a test, row 20 would get deleted too, even though it was supposed to stay as the "unique" duplicate because it was the "last man standing."

    In addition, if the duplications WITHIN the duplication set fails a test simultaneously to whereas there is not a single "winner", then delete every row WITHIN that duplication set.

    Example 1: Take a look at row 4, 5, and 6. All three pass the first test, so all three advance on to the second test; now all three fail the second test so all three get deleted and there is no "winner."

    Example 2: Take a look at row 13, 14, and 15. Row 13 fails the first test, so its automatically eliminated. Row 14 and 15 pass the first test so they advance to the 2nd test; however, row 14 and 15 both fail the second test simultaneously and both get deleted, therefore, there is not a single "winner" for this duplication set.

    Im thinking this has to be achieved through some type of VBA code, but any suggestions are greatly appreciated, thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: How to remove duplicates within duplication sets based on criteria?

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    http://www.excelguru.ca/forums/showt...ed-on-criteria
    http://www.mrexcel.com/forum/excel-q...-criteria.html

  3. #3
    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
    43,984

    Re: How to remove duplicates within duplication sets based on criteria?

    To one mass spec person from another mass spec person... Hello!!

    To return the unique m/z values use this, copied down:
    =IFERROR(INDEX($A$2:$A$41,MATCH(0,INDEX(COUNTIF($F$1:$F1,$A$2:$A$41),0),0)),"")

    To return the remaining values, use this array formula, copied across and down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

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

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

    Re: How to remove duplicates within duplication sets based on criteria?

    A double post and the attachment dropped off. Here's the file (I hope).
    Attached Files Attached Files

+ 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. Duplication remove with criteria
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2016, 10:23 PM
  2. Remove duplicates based on multiple criteria
    By cbwilliams in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-18-2015, 05:12 PM
  3. Code to remove duplicates based on a criteria
    By twizy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2014, 10:18 AM
  4. Code to remove duplicates based on a criteria
    By twizy in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 12-17-2014, 09:48 AM
  5. Replies: 0
    Last Post: 05-22-2014, 11:16 AM
  6. Replies: 10
    Last Post: 06-10-2013, 01:18 PM
  7. Remove duplicates based on criteria
    By keswickjeff in forum Excel General
    Replies: 2
    Last Post: 07-14-2011, 12: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