Results 1 to 7 of 7

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

Threaded View

gma 30K Rows: How Do I Identify... 02-20-2013, 02:49 AM
samba_ravi Re: 30K Rows: How Do I... 02-20-2013, 03:52 AM
gma Re: 30K Rows: How Do I... 02-20-2013, 02:51 PM
gma Re: 30K Rows: How Do I... 02-21-2013, 04:00 PM
arlu1201 Re: 30K Rows: How Do I... 02-20-2013, 04:02 AM
gma Re: 30K Rows: How Do I... 02-20-2013, 02:56 PM
gma Re: 30K Rows: How Do I... 03-04-2013, 12:03 AM
  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:

    Sub aaa()
      For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If Cells(i, 1) = Cells(i - 1, 1) And Cells(i, 2) = Cells(i - 1, 2) Then
          Cells(i, 1).EntireRow.Delete
          Cells(i - 1, 1).EntireRow.Delete
        End If
      Next i
    End Sub
    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.

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