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
Bookmarks