+ Reply to Thread
Results 1 to 7 of 7

30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

  1. #1
    Registered User
    Join Date
    02-15-2013
    Location
    SF, CA
    MS-Off Ver
    Excel 2011
    Posts
    5

    Unhappy 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    Hi there,

    I've lost sleep over this and would appreciate your help. Here's what I'm dealing with (I've attached a screen shot and an .xlsx file for reference):

    I have a file containing 30,000 rows of data.

    There are 5 column headers:
    Name | Date | Employee # | Qty. | Meal

    Among the 30,000 rows, there are 5,200 rows that are duplicates.

    What I'm trying to do:
    Use a formula or VBA code to find the duplicate ROWS (where all 5 cells in the row exactly match another row) and delete BOTH rows. I do not want to keep the Unique row, I want the set of matching rows deleted. I know how to filter, use conditional formatting and the "remove duplicates" button, but all of those options leave the unique row intact. Again, I want the unique row deleted, as well.
    The result would be as follows:

    30,000 rows to start
    delete 10,400 rows (the 5,200 rows x 2, since we're deleting BOTH the duplicate row and the row it duplicates.)
    =19,600 unique rows would remain.

    I've spent many hours searching for and trying formulas and VBA code to accomplish this, to no avail. I thought I found the solution in a closed thread on this forum, but I have not been able to make it return accurate results. It deletes far more lines than expected. Here's the code from that thread:

    Please Login or Register  to view this content.
    It was posted by Rylo, in this thread:
    http://www.excelforum.com/excel-form...cate-rows.html

    Note: the screen shot and .xlsx files that I've attached contain highlighted rows and purple text in some of the rows. That was not accomplished through conditional formatting; I formatted the rows like that so that you could see the matching rows.

    If anyone can keep me from having to manually delete 10,400 rows, I'd greatly appreciate it! Thanks for listening

    -gma
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by arlu1201; 02-20-2013 at 04:01 AM.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    try this code

    Please Login or Register  to view this content.
    Last edited by arlu1201; 02-20-2013 at 04:02 AM.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    Gma & Nflsales,

    I have added code tags to your posts. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    02-15-2013
    Location
    SF, CA
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    !!

    Thank you for the quick response, nflsales! I tried the code on a larger sample of about 100 rows and it worked beautifully! Now I'll try the full 30K, and report back; I have a good feeling about this

  5. #5
    Registered User
    Join Date
    02-15-2013
    Location
    SF, CA
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    Thank you for adding the tags, arlu1201. I'll remember to do that the next time I post, and will mark the thread as Solved when I've processed the larger data set!

    Cheers!

  6. #6
    Registered User
    Join Date
    02-15-2013
    Location
    SF, CA
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    Hi again!

    Reporting back, after trying your code on 30K rows. Didn't get the expected results, based on my calculations. At any rate, it works for smaller chunks of data, as I said yesterday, so I'll just sort by Employee Name and run the macro on one employee at a time, rather than all of them (unless you can suggest another solution.)

    Thanks and I'll report back later today!

    Cheers

  7. #7
    Registered User
    Join Date
    02-15-2013
    Location
    SF, CA
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: 30K Rows: How Do I Identify Duplicate Rows (across 5 Columns) and Delete BOTH Rows?

    Forgot to update this.

    It worked!! Thank you SO much, nflsales

    ~gma

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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