Sub test()
Dim Lc&, a, j$
Lc = Cells(1, Columns.Count).End(1).Column + 1
a = Cells(1).CurrentRegion
With CreateObject("scripting.dictionary")
For x = 2 To UBound(a)
j = Join(Array(a(x, 6), a(x, 8)), "-")
If Not .exists(j) Then
.Add j, 1 & "|" & a(x, 2)
Else
.Item(j) = Split(.Item(j), "|")(0) + 1 & "|" & IIf(Split(.Item(j), "|")(1) < a(x, 2), Split(.Item(j), "|")(1), a(x, 2))
End If
Next
For x = 2 To UBound(a)
j = Join(Array(a(x, 6), a(x, 8)), "-")
a(x, 3) = IIf(Split(.Item(j), "|")(0) > 1, Split(.Item(j), "|")(0), "-")
a(x, 4) = IIf(Split(.Item(j), "|")(0) > 1, Split(.Item(j), "|")(1), "-")
Next
Cells(1, Lc).Resize(UBound(a), 2) = Application.Index(a, Evaluate("row(1:" & UBound(a) & ")"), Array(3, 4))
End With
For x = 2 To UBound(a)
If Cells(x, Lc) <> "-" Then
Union(Cells(x, "F"), Cells(x, "H")).Interior.Color = vbRed
If Cells(x, "B") = Cells(x, Lc).Offset(, 1) Then Union(Cells(x, "L"), Cells(x, "O")).Interior.Color = 5296274
End If
Next
Columns(Lc).Resize(, 2).ClearContents
End Sub
Bookmarks