Good day,

I currently have a basic VBA to delete rows based om duplicate values in Column B.

I have dates in Column O. I want to delete the duplicate with the oldest date.

I am currently using this VBA:

Private Sub CommandButton2_Click()
LastRow = ActiveSheet.UsedRange.Row - 1 + _
    ActiveSheet.UsedRange.Rows.Count

For RowNum = 2 To LastRow
    If (Range("B" & RowNum) = Range("B" & RowNum + 1)) Then
    Range("B" & RowNum).EntireRow.Clear
    End If
Next RowNum

Range("A2:Z" & LastRow).Sort key1:=Range("B2:B" & LastRow), _
order1:=xlAscending, Header:=xlNo
End Sub
Can anyone assist me as to how I can change my VBA code to delete the duplicate with the oldest date?