Thanks for your reply:-
The code below should give better results, as it checks each Unique person against each duplicate of that unique person and returns the results starting column "E" .
NB:- Your actual data is expected to start on row (2) , as per your thread data.
Sub MG06Nov30
Dim Rng As Range
Dim Dn As Range
Dim n As Long
Dim Q
Dim oMax As Long
Dim oCol As Long
Dim iCol As Long
Dim Rw As Long
Dim ac As Long
Dim Fd As Boolean
Set Rng = Range(Range("C2"), Range("C" & Rows.Count).End(xlUp))
ReDim nR(1 To Rng.Count, 1 To Rng.Count)
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value & "," & Dn.Offset(, 1).Value) Then
n = n + 1
Set nR(n, 1) = Dn
.Add Dn.Value & "," & Dn.Offset(, 1).Value, Array(nR, n, 1)
Else
Q = .Item(Dn.Value & "," & Dn.Offset(, 1).Value)
Q(2) = Q(2) + 1
Set nR(Q(1), Q(2)) = Dn
oMax = Application.Max(oMax, Q(2))
.Item(Dn.Value & "," & Dn.Offset(, 1).Value) = Q
End If
Next
End With
ReDim Preserve nR(1 To Rng.Count, 1 To oMax)
For Rw = 1 To UBound(nR, 1)
For oCol = 1 To UBound(nR, 2)
If Not IsEmpty(nR(Rw, oCol)) Then
For iCol = oCol + 1 To UBound(nR, 2)
If Not IsEmpty(nR(Rw, iCol)) Then
If Abs(DateDiff("n", nR(Rw, oCol).Offset(, -2) + nR(Rw, oCol).Offset(, -1), nR(Rw, iCol).Offset(, -2) + nR(Rw, iCol).Offset(, -1))) <= 30 Then
Fd = True
End If
If Fd = True Then
ac = ac + 1
nR(Rw, oCol).Offset(, 1 + ac).EntireColumn.ClearContents
Cells(1, ac + 4) = nR(Rw, oCol)
nR(Rw, oCol).Offset(, 1 + ac) = "Dup " & ac
nR(Rw, iCol).Offset(, 1 + ac) = "Dup " & ac
Fd = False
End If
End If
Next iCol
End If
Next oCol
Next Rw
End Sub
Regards Mick
Bookmarks