Hi, Try this:-
This code Is Based on Column "F" (Peoples Names) but included related data from the Columns "B" To "E" and the dates in column "G".
NB:- This extra will be Data in columns "B" To "E" for each first found individual Name in column "F", Subsequent different data in columns "B" to "E" wil not be found.
The results are in sheet(2) starting "A2".
Sub Trans2()
Dim a, K(), Q(), i As Long, n As Long, lCol As Long
Dim Rng As Range, c
Set Rng = Range(Range("B1"), Range("G" & Rows.Count).End(xlUp))
a = Rng.Value
ReDim K(1 To UBound(a, 1), 1 To Columns.Count)
With CreateObject("scripting.dictionary")
.comparemode = vbTextCompare
For i = 1 To UBound(a, 1)
If Not .Exists(a(i, 5)) Then
n = n + 1
K(n, 1) = a(i, 1): K(n, 2) = a(i, 2): K(n, 3) = a(i, 3)
K(n, 4) = a(i, 4): K(n, 5) = a(i, 5)
K(n, 6) = Format(a(i, 6), "dd/mm/yy")
.Add a(i, 5), Array(n, 6)
Else
Q = .Item(a(i, 5))
Q(1) = Q(1) + 1
K(Q(0), Q(1)) = Format(a(i, 6), "dd/mm/yy")
lCol = Application.Max(lCol, Q(1))
.Item(a(i, 5)) = Q
End If
Next
With Sheets("Sheet2")
.Range("A2").Resize(n, lCol).Value = K
.Columns.AutoFit
End With
End With
End Sub
Regards Mick
Bookmarks