shantraj.antin@gmail.com
Member
Hi All,
I was using the below code to remove duplicate rows.
In the current scenario I have couple of cells which are merged in Column A. If I run the macro I am losing the non duplicate values.
Kindly help me to revisit this code so that my Column A merged cells remain same and one of the duplicate rows gets deleted.
Please find the attached sample file.
I was using the below code to remove duplicate rows.
In the current scenario I have couple of cells which are merged in Column A. If I run the macro I am losing the non duplicate values.
Kindly help me to revisit this code so that my Column A merged cells remain same and one of the duplicate rows gets deleted.
Please find the attached sample file.
Code:
Sub Remove_Duplicates()
Dim LastRowcheck As Long, n1 As Long
Dim DelRange As Range
With Worksheets("JobDetails")
LastRowcheck = .Range("B" & .Rows.Count).End(xlUp).Row
For n1 = 1 To LastRowcheck
If .Cells(n1, 1).Value = Cells(n1 + 1, 1).Value Then
If DelRange Is Nothing Then
Set DelRange = .Rows(n1)
Else
Set DelRange = Union(DelRange, .Rows(n1))
End If
End If
Next n1
If Not DelRange Is Nothing Then DelRange.Delete
End With
End Sub