The following code works fine if the data is grouped (not necessarily sorted) by column B (but not necessarily by column A), this code will delete the duplicates rows, but retaining the latest entry (by column A) of each name in column B.
Unfortunately, my data in column B is not grouped (don't want it necessarily) to retain the original order.
I would like the code to perform the function described above, i.e., delete the duplicates rows, but retaining the latest entry (by column A) of each name in column B without having the data grouped.
Also, I need at the same time to delete the same rows that are removed in columns C, D, and E?
Can the code be modified to do this?
Thanks,
Art
Code:
Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("B2").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "B").Value = Cells(RowNdx - 1, "B").Value Then
If Cells(RowNdx, "A").Value <= Cells(RowNdx - 1, "A").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
Next RowNdx
End Sub
Unfortunately, my data in column B is not grouped (don't want it necessarily) to retain the original order.
I would like the code to perform the function described above, i.e., delete the duplicates rows, but retaining the latest entry (by column A) of each name in column B without having the data grouped.
Also, I need at the same time to delete the same rows that are removed in columns C, D, and E?
Can the code be modified to do this?
Thanks,
Art