+ Reply to Thread
Results 1 to 6 of 6

Removing duplicate rows based on a value in one of the two columns

  1. #1
    Registered User
    Join Date
    10-03-2019
    Location
    London
    MS-Off Ver
    2013
    Posts
    7

    Removing duplicate rows based on a value in one of the two columns

    Hello
    I have a large sheet with 2 columns. One is an ID field and one is an ethnic group field. For each unique ID I want to delete the row which has ethnic group "Unknown" e.g for ID = 1 or 2 but still keep the rows where a single ID exists with ethnic group = unknown e.g. ID 5 in my example below...

    ID ethnic group
    1 Unknown
    1 White
    2 Unknown
    2 White
    3 White
    4 White
    5 Unknown


    Can anyone help? Much appreciated
    Can't get attachments to work on this post

  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,662

    Re: Removing duplicate rows based on a value in one of the two columns

    Do you want a formula to give you the results in another place on the same/different sheet, or VBA to physically remove the rows?

    For reference: the attachment icon doesn't work at the moment. So,... instead click on Go Advanced (below the Edit Window) while composing your reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.
    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
    10-03-2019
    Location
    London
    MS-Off Ver
    2013
    Posts
    7

    Re: Removing duplicate rows based on a value in one of the two columns

    Dear Glen
    Thanks for your reply. I have not used VBA code before so putting the results on a different sheet would be better.
    I have attached a small sample worksheet.

    I hope it worked

    Kind regards

    Kate
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,938

    Re: Removing duplicate rows based on a value in one of the two columns

    I am going to work with the data in post #1.
    This proposal employs a helper column which may moved and/or hidden for aesthetic purposes.
    The helper column is populated using: =IF(AND(B2="Unknown",COUNTIFS(A$2:A$8,A2)>1),0,1)
    The formula that populates the final result, as modeled on sheet2, is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    10-03-2019
    Location
    London
    MS-Off Ver
    2013
    Posts
    7

    Re: Removing duplicate rows based on a value in one of the two columns

    Thank you so much JeteMC - this works a treat.

    very happy indeed

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,938

    Re: Removing duplicate rows based on a value in one of the two columns

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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] Removing rows so that 1 of each id remains based on 2 columns
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-11-2018, 03:12 PM
  2. Removing duplicate rows depending on range of columns
    By simontlc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-09-2016, 12:31 PM
  3. [SOLVED] Removing rows that contain duplicate information in 3 columns
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2015, 02:33 PM
  4. Removing duplicate rows using only a few columns.
    By HorribleZane13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2015, 09:34 AM
  5. Removing Duplicate Rows based on 2 columns
    By metalpoker in forum Excel Programming / VBA / Macros
    Replies: 37
    Last Post: 10-14-2011, 05:28 AM
  6. Removing duplicate rows, based on ColumnA
    By JoshD75 in forum Excel General
    Replies: 1
    Last Post: 09-01-2011, 04:47 PM
  7. Replies: 1
    Last Post: 04-01-2005, 07:06 PM

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