Forum Discussion
YDN10
Jul 03, 2022Copper Contributor
Code to Delete Duplicates After Copying To Another Sheet
Hi All, Hope you are all well! Background: This is my test excel sheet: The duplicates column is created from this excel function: =IF(COUNTIF($A$2:$A2,A2)>1, "Duplicate",""). I will have lot...
NikolinoDE
Jul 03, 2022Platinum Contributor
Sub DellDuplicate()
Dim i As Integer
Dim intLR As Integer
intLR = Sheets("Sheet1").Range("D65536").End(xlUp).Row
With Sheets("Sheet1")
For i = 1 To intLR
If InStr(1, .Cells(i, 4).Value, "Duplicate") Then
.Cells(i, 1).EntireRow.Delete
i = i - 1
Else
End If
Next i
End With
End Sub
Forgive me if I didn't read through your text due to time constraints.
Send you this little code as I could understand it on the fly.
Maybe it helps, if not just ignore it :).
I know I don't know anything (Socrates)
- YDN10Jul 03, 2022Copper ContributorThank you NikolinoDE.
I used a counter variable in a For Next loop which is working for now. It moves duplicates to the next sheet.
Now I want to automate the new sheet's creation and automatically run the macro per new sheet until there are no sheets with duplicates.