Something like this. Not to much modifictions
Option Explicit
Sub abc()
Dim a, i As Long
With Worksheets("test")
a = .Range("a1", .Cells(Rows.Count, "e").End(xlUp))
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For i = 1 To UBound(a)
If Not .exists(a(i, 1)) Then
'.Item(a(i, 1)) = a(i, 1) & ";" & a(i, 2) & ";" & a(i, 3) & ";" & a(i, 4) & ";" & a(i, 5)
'below is the same as above but using join function.
.Item(a(i, 1)) = Join(Array(a(i, 1), a(i, 2), a(i, 3), a(i, 4), a(i, 5)), ";")
Else
If Split(.Item(a(i, 1)), ";")(3) > a(i, 3) Then
.Item(a(i, 1)) = Join(Array(a(i, 1), a(i, 2), a(i, 3), a(i, 4), a(i, 5)), ";")
End If
End If
Next
a = .items
End With
With Worksheets("output")
For i = 0 To UBound(a)
.Cells(i + 1, 1).Resize(, 5) = Split(a(i), ";")
Next
End With
End Sub
Bookmarks