Hi,
I wrote a code that which allows to delete repetitive data with the same columns and then defined a button for this but I have to click the button more than four or five times to delete the duplicate data. For example; It deletes 5 or 10 rows every time I click it. When the total data also does not decrease the number of rows, then I understand that all matching rows are deleted. I want to delete repetitive rows as stated in the attachment in one click and I want it to auto-loop through newly updated rows as rows are deleted, but I can't. Anyone who can help?
Thanks,
Sub y()
Sayfa1.Range("A2").Sort [A2], Order1:=xlDescending
For i = 2 To Sayfa1.UsedRange.Rows.Count
Sayfa1.Range("B2").Sort [B2], Order1:=xlDescending
If Sayfa1.Cells(i, 1) = Sayfa1.Cells(i + 1, 1) Then
If Sayfa1.Cells(i, 2) = Sayfa1.Cells(i + 1, 2) Then
If Sayfa1.Cells(i, 8) = "NOK" And Sayfa1.Cells(i + 1, 8) = "NOK" Then
Sayfa1.UsedRange.Rows(i + 1).Delete
ElseIf Sayfa1.Cells(i, 8) = "OK" And Sayfa1.Cells(i + 1, 8) = "OK" Then
Sayfa1.UsedRange.Rows(i + 1).Delete
End If
End If
End If
Next
End Sub
I wrote a code that which allows to delete repetitive data with the same columns and then defined a button for this but I have to click the button more than four or five times to delete the duplicate data. For example; It deletes 5 or 10 rows every time I click it. When the total data also does not decrease the number of rows, then I understand that all matching rows are deleted. I want to delete repetitive rows as stated in the attachment in one click and I want it to auto-loop through newly updated rows as rows are deleted, but I can't. Anyone who can help?
Thanks,
Sub y()
Sayfa1.Range("A2").Sort [A2], Order1:=xlDescending
For i = 2 To Sayfa1.UsedRange.Rows.Count
Sayfa1.Range("B2").Sort [B2], Order1:=xlDescending
If Sayfa1.Cells(i, 1) = Sayfa1.Cells(i + 1, 1) Then
If Sayfa1.Cells(i, 2) = Sayfa1.Cells(i + 1, 2) Then
If Sayfa1.Cells(i, 8) = "NOK" And Sayfa1.Cells(i + 1, 8) = "NOK" Then
Sayfa1.UsedRange.Rows(i + 1).Delete
ElseIf Sayfa1.Cells(i, 8) = "OK" And Sayfa1.Cells(i + 1, 8) = "OK" Then
Sayfa1.UsedRange.Rows(i + 1).Delete
End If
End If
End If
Next
End Sub