I'm not sure that code is giving you the right results. I think its possible giving you cases where row data "A,B,C" only appears onces on one of the sheets.
Below is a differents code that hopefully stops that happening, perhaps you would like to try it.
Results on sheet "New Results"
Sub MG14Oct55
Dim Rng1 As Range
Dim Dn As Range
Dim Rng2 As Range
Dim oTrip As String
Dim c As Long
Dim fd As Boolean
Dim Dic1 As Object
Dim Dic2 As Object
Dim Q
Dim k
Dim t
Dim Temp As Variant
t = Timer
With Sheets("New Results")
Temp = .Rows("1:2").Value
.UsedRange.ClearContents
.Rows("1:2").Value = Temp
End With
With Sheets("Data 1")
Set Rng1 = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
End With
With Sheets("Data 2")
Set Rng2 = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
End With
Set Dic1 = CreateObject("scripting.dictionary")
Dic1.CompareMode = vbTextCompare
For Each Dn In Rng1
oTrip = Dn & "," & Dn(, 2) & "," & Dn(, 3)
If Not Dic1.exists(oTrip) Then
Dic1.Add oTrip, Dn
Else
Set Dic1.Item(oTrip) = Union(Dic1.Item(oTrip), Dn)
End If
Next
Set Dic2 = CreateObject("scripting.dictionary")
Dic2.CompareMode = vbTextCompare
For Each Dn In Rng2
oTrip = Dn & "," & Dn(, 2) & "," & Dn(, 3)
If Not Dic2.exists(oTrip) Then
Dic2.Add oTrip, Dn
Else
Set Dic2.Item(oTrip) = Union(Dic2.Item(oTrip), Dn)
End If
Next
ReDim Ray(1 To Dic1.Count + Dic2.Count, 1 To 9)
For Each k In Dic1.Keys
If Dic2.exists(k) Then
If Dic1.Item(k).Count > 1 And Dic2.Item(k).Count > 1 Then
c = c + 1
Ray(c, 1) = Split(k, ",")(0)
Ray(c, 2) = Split(k, ",")(1)
Ray(c, 3) = Split(k, ",")(2)
Ray(c, 4) = Application.Sum(Dic1.Item(k).Offset(, 3)) / Dic1.Item(k).Count
Ray(c, 5) = Application.Sum(Dic1.Item(k).Offset(, 4)) / Dic1.Item(k).Count
Ray(c, 6) = Application.Sum(Dic1.Item(k).Offset(, 5)) / Dic1.Item(k).Count
Ray(c, 7) = Application.Sum(Dic2.Item(k).Offset(, 3)) / Dic2.Item(k).Count
Ray(c, 8) = Application.Sum(Dic2.Item(k).Offset(, 4)) / Dic2.Item(k).Count
Ray(c, 9) = Application.Sum(Dic2.Item(k).Offset(, 5)) / Dic2.Item(k).Count
End If
End If
Next k
Sheets("New Results").Range("A3").Resize(c, 9) = Ray
MsgBox Timer - t
End Sub
Regards Mick
Bookmarks