ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Add one more criteria (https://www.excelbanter.com/excel-worksheet-functions/149167-add-one-more-criteria.html)

Steved

Add one more criteria
 
Hello from Steved

The below Formula finds Duplicates and deletes.

Question please How do I also ask the formula to check Column E

Thefore the find Criteria would be Columns "A", "D", "E" then the duplicates
found Delete.

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "A").Value = Cells(RowNdx - 1, "A").Value Then
If Cells(RowNdx, "D").Value <= Cells(RowNdx - 1, "D").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
Next RowNdx
End Sub

Thankyou

Bob Phillips

Add one more criteria
 
Hi SteveD

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "A").Value = Cells(RowNdx - 1, "A").Value Then
If Cells(RowNdx, "D").Value <= Cells(RowNdx - 1, "D").Value Then
If Cells(RowNdx, "E").Value <= Cells(RowNdx - 1, "E").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
End If
Next RowNdx
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Steved" wrote in message
...
Hello from Steved

The below Formula finds Duplicates and deletes.

Question please How do I also ask the formula to check Column E

Thefore the find Criteria would be Columns "A", "D", "E" then the
duplicates
found Delete.

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "A").Value = Cells(RowNdx - 1, "A").Value Then
If Cells(RowNdx, "D").Value <= Cells(RowNdx - 1, "D").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
Next RowNdx
End Sub

Thankyou




Steved

Add one more criteria
 
Thankyou Bob

"Bob Phillips" wrote:

Hi SteveD

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "A").Value = Cells(RowNdx - 1, "A").Value Then
If Cells(RowNdx, "D").Value <= Cells(RowNdx - 1, "D").Value Then
If Cells(RowNdx, "E").Value <= Cells(RowNdx - 1, "E").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
End If
Next RowNdx
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Steved" wrote in message
...
Hello from Steved

The below Formula finds Duplicates and deletes.

Question please How do I also ask the formula to check Column E

Thefore the find Criteria would be Columns "A", "D", "E" then the
duplicates
found Delete.

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "A").Value = Cells(RowNdx - 1, "A").Value Then
If Cells(RowNdx, "D").Value <= Cells(RowNdx - 1, "D").Value Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
Next RowNdx
End Sub

Thankyou






All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com