Deleting Duplicate Rows

unit213

Active Member
Joined
Jul 11, 2003
Messages
427
I know this topic has been discussed alot, but I can't find the solution I need through searching.

I have a roughly 10,000 rows of data that may contain duplicate entries. There are only 4 columns (A:D). I need to delete the row only if all 4 columns are duplicates. Here's an example:

07 Blue Car 1000
07 Blue Car 3000
07 Red Truck 10000
07 Red Truck 10000
07 White Van 40000
07 White Van 40000
07 White Van 42000

It should look like this after deleting duplicates:

07 Blue Car 1000
07 Blue Car 3000
07 Red Truck 10000
07 White Van 40000
07 White Van 42000

Another problem is that I want one duplicate entry to remain as in the example above. The rows containing "white" and "van" both have 40000 listed in them. I need one of those rows to remain.

Can anyone help out? I'd greatly appreciate it. Please let me know if I need to clarify.

Thanks,

Dan
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
How about the following code:

for r = 1 to Range("A65535").End(xlUp).row
cells(r,10) = r
cells(r,11) = Cells(r, 1) & Cells(r, 2) & Cells(r, 3) & Cells(r, 4)
next r


Cells.Select
Selection.Sort Key1:=Range("K1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


Set currentCell = Range("K1")
Do While Not IsEmpty(currentCell)
Set nextCell = currentCell.Offset(1, 0)
If nextCell.Value = currentCell.Value Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Loop


Cells.Select
Selection.Sort Key1:=Range("J1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Range(Columns(10), Columns(11)).Select
Selection.Delete Shift:=xlToLeft
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top