[RESOLVED] Delete All but One Duplicate Row in Worksheet
I have a single worksheet with (let's say, for simplicity's sake) fifteen rows and ten columns. Rows number 2, 6 and 9 are exact duplicates of each other in all cells. How can I search through all of the rows, find the duplicates, and delete all but one of them (essentially keeping only one of each duplicate row? Below is some code I found that deletes ALL duplicate rows, but I want to keep one of them... Any suggestions?
Code:
'Delete Duplicate Rows
For i = 1 To Worksheets("Overview").UsedRange.Rows.Count
For j = Worksheets("Overview").UsedRange.Rows.Count To 1 Step -1
If Worksheets("Overview").Cells(i, 1) = Worksheets("Overview").Cells(j, 1) Then Worksheets("Overview").Rows(j).Delete
Next j
Next i
Re: Delete All but One Duplicate Row in Worksheet
try
vb Code:
For i = 1 To Worksheets("Overview").UsedRange.Rows.Count
For j = Worksheets("Overview").UsedRange.Rows.Count To i + 1 Step -1
If Worksheets("Overview").Cells(i, 1) = Worksheets("Overview").Cells(j, 1) Then Worksheets("Overview").Rows(j).Delete
Next j
Next i
Re: Delete All but One Duplicate Row in Worksheet
That works BRILLIANTLY. THank yoU!