+ Reply to Thread
Results 1 to 8 of 8

Remove duplicates in column A, leaving the one with the highest number in column B?

  1. #1
    Registered User
    Join Date
    03-16-2021
    Location
    London, England
    MS-Off Ver
    365
    Posts
    28

    Remove duplicates in column A, leaving the one with the highest number in column B?

    Name Number
    Bill 1345
    Debs 675
    Steve 87
    James 42
    Steve 34
    James 23
    Debs 11
    Bill 4

    I want to remove all duplicates in Column A (Name), but leaving the one with the highest associated number in B (Number).

    So in the above, it would remove Steve 34 because 87 is the highest.

    It would end up as:

    Name Number
    Bill 1345
    Debs 675
    Steve 87
    James 42

    I thought if I did a Sort (highest first) and then removed duplicate, Excel would start from the top and work it's way down - meaning any duplicate can be removed as the number is lower the one above, anyway - doesn't seem to work.

  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 2406
    Posts
    44,231

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    A formula any use to you:

    =LET(A,A2:A9,B,B2:B9,C,UNIQUE(A),D,MAP(C,LAMBDA(z,TAKE(SORT(FILTER(B,A=z),,-1),1))),HSTACK(C,D))
    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
    Registered User
    Join Date
    03-16-2021
    Location
    London, England
    MS-Off Ver
    365
    Posts
    28

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    Quote Originally Posted by Glenn Kennedy View Post
    A formula any use to you:

    =LET(A,A2:A9,B,B2:B9,C,UNIQUE(A),D,MAP(C,LAMBDA(z,TAKE(SORT(FILTER(B,A=z),,-1),1))),HSTACK(C,D))
    Nice - so with a lot more rows, it's simply a case of changing A9 and B9?

  4. #4
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,076

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    The easiest way is to use PivotTable, with Name in Rows and Number in Values, and Summarize Values by Max.

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

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    Yes. That's all's needed.

    Or you could do this (make it future proof, - just don't go mad with the end point):

    =LET(A,TOCOL(A2:A100,1),B,TOCOL(B2:B100,1),C,UNIQUE(A),D,MAP(C,LAMBDA(z,TAKE(SORT(FILTER(B,A=z),,-1),1))),HSTACK(C,D))

    You're welcome. Thanks for letting us know that you got an answer.




    Please take a moment and consider clicking the "Add Reputation" button at the foot of any of the posts of anyone who helped you reach a solution here today.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,299

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    Power Query
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-16-2021
    Location
    London, England
    MS-Off Ver
    365
    Posts
    28

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    Quote Originally Posted by Glenn Kennedy View Post
    Yes. That's all's needed.

    Or you could do this (make it future proof, - just don't go mad with the end point):

    =LET(A,TOCOL(A2:A100,1),B,TOCOL(B2:B100,1),C,UNIQUE(A),D,MAP(C,LAMBDA(z,TAKE(SORT(FILTER(B,A=z),,-1),1))),HSTACK(C,D))

    You're welcome. Thanks for letting us know that you got an answer.




    Please take a moment and consider clicking the "Add Reputation" button at the foot of any of the posts of anyone who helped you reach a solution here today.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

    Ok, ran into a problem here.

    How do I increase the E/F columns from 88 to more like 500? When I click on the area at the top to edit the function, it disappears. So I can't edit it.
    Last edited by burnleysteve; 01-06-2024 at 09:49 AM.

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

    Re: Remove duplicates in column A, leaving the one with the highest number in column B?

    Given that there are only 2 columns in columns E & F, I have no idea where you get a figure of 88 from. I have absolutely no idea where 500 columns comes into it...

    You will need to provide an updated sample. Did my formula work fully for the TWO columns in your original sample

+ 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. Replies: 4
    Last Post: 03-18-2021, 09:10 AM
  2. [SOLVED] Remove duplicates except those where value in column B is highest
    By AD_CTCH in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-28-2019, 09:08 AM
  3. Macro to remove duplicate data in one column and keep highest value in another column
    By Renejorgensen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2016, 08:56 AM
  4. Remove Duplicates While Leaving Blanks
    By gitpicker in forum Excel General
    Replies: 2
    Last Post: 08-30-2016, 12:31 PM
  5. Remove 'duplicates' to leaving lowest value
    By alseeon in forum Excel General
    Replies: 9
    Last Post: 06-29-2015, 06:22 AM
  6. Replies: 1
    Last Post: 06-10-2013, 07:08 PM
  7. Replies: 3
    Last Post: 08-10-2006, 11: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