Reputation: 27
I have an excel spreadsheet with two columns: Column A contains a list of names and Column B contains dates.
I want to get rid of duplicate entries based on dates. This is an example
A B
John 01/03/2020
John 01/03/2020
Bob 01/03/2020
John 02/03/2020
Bob 02/03/2020
Bob 02/03/2020
I want to remove duplicates that have the same date, so the final result should be:
A B
John 01/03/2020
Bob 01/03/2020
John 02/03/2020
Bob 02/03/2020
Upvotes: 0
Views: 536
Reputation: 8230
If you decide to use VBA try:
Sub test()
Dim i As Long, y As Long, Lastrow As Long
Dim strName As String
Dim dtDate As Date
With ThisWorkbook.Worksheets("Sheet1")
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = Lastrow To 1 Step -1
For y = i - 1 To 1 Step -1
If (.Range("A" & i).Value = .Range("A" & y).Value) And (.Range("B" & i).Value = .Range("B" & y).Value) Then
.Rows(i).EntireRow.Delete
End If
Next y
Next i
End With
End Sub
Upvotes: 0