HI All,
When I am using the below code for deleting the duplicate I am getting error 1004 only when sheets does not have duplicate.
Please can some one help me to avoid this error.
Sub duplicateDelNH31()
Dim s1 As Worksheet, s2 As Worksheet
Dim lr, lr2
Dim j As Long, i As Long
Set s1 = Sheets("NH3"): Set s2 = Sheets("Utility")
lr = s1.Cells(1).CurrentRegion.Resize(, 1).Value
lr2 = s2.Cells(1).CurrentRegion.Resize(, 1).Value
For j = 2 To UBound(lr2)
For i = 2 To UBound(lr)
If lr2(j, 1) = lr(i, 1) Then lr2(j, 1) = vbNullString: Exit For
Next i
Next j
s2.Columns(1).ClearContents
s2.Cells(1).Resize(UBound(lr2)) = lr2
s2.Columns(1).SpecialCells(4).EntireRow.Delete
MsgBox "Task Completed"
End Sub
Thanks in advance.
Regards,Waqar
Bookmarks