+ Reply to Thread
Results 1 to 4 of 4

Delete Duplicate Rows, if column does not contain x

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2013
    Posts
    25

    Delete Duplicate Rows, if column does not contain x

    Hello!

    I have an excel VB script/Macro that deletes duplicate rows, but I now need to expand it and I can't figure out how (& I’m limited for time):

    What I want to do is: Compare columns A, B for duplicate rows, and if duplicate row exists, ONLY delete if column D does not say “Closed” or “Abandoned”.

    Any suggestions on how to search sheet for duplicates rows based on column A B, and only delete row if column D of the duplicate row does not say “Closed” or “Abandoned”?

    (At any given time, there is 100 to 3000 rows of data; thus, do not want to use filters or conditional formatting, or anything manual to visually search for duplicates and delete).

    Example data:
    123 John Apple Open ** This row would be deleted
    124 Mary Apple Closed
    125 Sara Apple Open
    123 John Apple Closed
    123 John Apple Pending ** This row would be deleted


    Example delete duplicate VB/Macro I had previously used:
    'delete duplicates rows
    destSheet.UsedRange.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes

    Thank-you,
    Julie!

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Delete Duplicate Rows, if column does not contain x

    Hi Julie,

    Try this macro (though initially on a copy of your data as the results cannot be undone if they're not as expected) while on the sheet with the data:

    Please Login or Register  to view this content.
    Regards,

    Robert
    Last edited by Trebor76; 11-13-2015 at 11:11 PM.
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Delete Duplicate Rows, if column does not contain x

    Hi Julie
    Here's another routine that I think does what you want. I've assumed it's sheet 1 & the top row of the data is row 5, change the numbers to suit.
    It sorts the data into ascending order by column A & then column B,it doesn't delete any columns, only duplicate rows that don't contain Closed or Abandoned in column D.
    As Trebor says, test it on a copy
    Cheers

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

  4. #4
    Registered User
    Join Date
    02-10-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Delete Duplicate Rows, if column does not contain x

    Hi Guys - I just got back to this today & I'll try these out and let you know. Thx J!

+ 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] Delete entire Rows if Column value is unique OR Duplicate is less than three
    By analystbank in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2014, 12:09 PM
  2. Replies: 5
    Last Post: 11-12-2012, 08:38 PM
  3. Replies: 4
    Last Post: 01-25-2011, 08:03 PM
  4. Replies: 5
    Last Post: 06-11-2009, 08:57 AM
  5. Replies: 2
    Last Post: 01-13-2009, 01:42 PM
  6. Replies: 3
    Last Post: 05-16-2005, 06:06 PM
  7. [SOLVED] I want to delete rows with duplicate entries within one column.
    By kini olegario in forum Excel General
    Replies: 1
    Last Post: 01-14-2005, 10:07 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