+ Reply to Thread
Results 1 to 4 of 4

Eliminate duplicates with preference to another column

  1. #1
    Registered User
    Join Date
    10-21-2016
    Location
    Chicago, IL
    MS-Off Ver
    MAC 2011
    Posts
    4

    Eliminate duplicates with preference to another column

    Hi everyone, got a somewhat complicated questions. Not sure if excel can do this. I have an excel table with duplicates in column b, and I want to eliminate the duplicates, but with preference to the corresponding value in column a. Is there a way to write a function to get rid of duplicates with this sort of preference?

    Secondary question, I am trying to do this in a way so that it populates the cleaned version into a new sheet.

    Let me know if you have any ideas!

    Thanks,
    Matt

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Eliminate duplicates with preference to another column

    I don't know what this means. Please clarify

    but with preference to the corresponding value in column a.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-21-2016
    Location
    Chicago, IL
    MS-Off Ver
    MAC 2011
    Posts
    4

    Re: Eliminate duplicates with preference to another column

    Hi Alan,
    I guess I wasn't very clear - I'll give you an example. I am trying to calculate the population of a country, say Pakistan, and I have two sources for this info. I want to eliminate one, with preference to a specific source. See below

    Source Country Population
    Wikipedia Pakistan 10,000,000
    Britannica Pakistan 11,000,000

    This is in the context of having many different country's information that I want to import into a new tab. I want to write a formula that only imports one row for each country, and the code would say something like "always prefer wikipedia in case of duplicates". I know this is a hard ask, but would love to hear any creative solutions!

    Thanks

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Eliminate duplicates with preference to another column

    This code will filter out all non-Wikipedia results. It sorts on country first and then loops through Column A looking for non Wikipedia results when there is a country match.

    Please Login or Register  to view this content.

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

+ 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. Looking to Eliminate Duplicates between 2 columns.
    By ontheroad1015 in forum Excel General
    Replies: 2
    Last Post: 07-10-2016, 06:45 AM
  2. Replies: 2
    Last Post: 01-02-2015, 10:11 AM
  3. how to eliminate duplicates.
    By comp23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2012, 07:59 AM
  4. [SOLVED] Need to eliminate duplicates and originals
    By geffsta in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-31-2012, 09:37 AM
  5. Eliminate Duplicates
    By TShelt in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2011, 11:47 AM
  6. Eliminate duplicates in worksheets
    By maxebi in forum Excel General
    Replies: 3
    Last Post: 10-09-2010, 09:56 AM
  7. Create a list from a column and eliminate duplicates
    By Jogier505 in forum Excel General
    Replies: 11
    Last Post: 08-05-2010, 02:25 AM

Tags for this Thread

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