I need help please, i want to delete raws if cells in columns A and B are duplicated, but i want to keep the last duplicated raw and delete all previous ones.
i got this code, it works but it keeps the fist raw not the last.
Sub DelDuplicates()
'
' Macro working but keeps 1st record and delete the rest
'
Dim current As String
ActiveSheet.Range("A1").Activate
Do While ActiveCell.Value <> ""
current = ActiveCell.Address
ActiveCell.Offset(1, 0).Activate
Do While ActiveCell.Value <> ""
If ((ActiveSheet.Range(current).Value = ActiveCell.Value) And (ActiveSheet.Range(current).Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value)) Then
' next raw
Selection.Offset(1, 0).Select
' end of next raw
ActiveSheet.Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(-1, 0).Activate
End If
Loop
ActiveSheet.Range(current).Offset(1, 0).Activate
Loop
End Sub
i got this code, it works but it keeps the fist raw not the last.
Sub DelDuplicates()
'
' Macro working but keeps 1st record and delete the rest
'
Dim current As String
ActiveSheet.Range("A1").Activate
Do While ActiveCell.Value <> ""
current = ActiveCell.Address
ActiveCell.Offset(1, 0).Activate
Do While ActiveCell.Value <> ""
If ((ActiveSheet.Range(current).Value = ActiveCell.Value) And (ActiveSheet.Range(current).Offset(0, 1).Value = ActiveCell.Offset(0, 1).Value)) Then
' next raw
Selection.Offset(1, 0).Select
' end of next raw
ActiveSheet.Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(-1, 0).Activate
End If
Loop
ActiveSheet.Range(current).Offset(1, 0).Activate
Loop
End Sub