Try this:-
Data sheet1 starting "A1"
Results sheet2 starting "A1.
Sub MG29Mar07
Dim Rng As Range, Dn As Range, n As Long
Dim Dic As Object
Dim Cols As String
Dim c As Long
With Sheets("Sheet1")
Set Rng = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp))
End With
Set Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare
For Each Dn In Rng
Cols = Dn & Dn.Offset(, 1)
Set Dic.Item(Cols) = Dn
Next
Dim k
For Each k In Dic.keys
For Each Dn In Rng
If Not k = Dn & Dn.Offset(, 1) Then
c = c + 1
With Sheets("Sheet2")
.Cells(c, "A") = Dic.Item(k)
.Cells(c, "B") = Dic.Item(k).Offset(, 1)
.Cells(c, "C") = Dic.Item(k).Offset(, 2)
.Cells(c, "D") = Dn.Offset(, 2)
.Cells(c, "E") = Dn.Offset(, 1)
.Cells(c, "F") = Dn
End With
End If
Next Dn
Next k
Dim Txt As String
Dim Dic1 As Object
Dim nRng As Range
With Sheets("Sheet2")
Set Rng = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp))
End With
Set Dic1 = CreateObject("scripting.dictionary")
Dic1.CompareMode = vbTextCompare
For Each Dn In Rng
Txt = Dn & Dn(, 2) & Dn(, 5) & Dn(, 6)
Set Dic1.Item(Txt) = Dn
Next Dn
Dim t
For Each Dn In Rng
Txt = Dn(, 6) & Dn(, 5) & Dn(, 2) & Dn
If Dic1.exists(Txt) Then
If Dn.Row > Dic1.Item(Txt).Row Then
If nRng Is Nothing Then
Set nRng = Dn
Else
Set nRng = Union(nRng, Dn)
End If
End If
End If
Next Dn
If Not nRng Is Nothing Then nRng.EntireRow.Delete
End Sub
Regards Mick
Bookmarks