Hi aman1234
Sub ertert()
Dim x, y(), i&, j&, k&, n&
With Sheets("tblmain")
x = .Range("A1:C" & .Cells(Rows.Count, 1).End(xlUp).Row).Value
End With
Dim d As Object: Set d = CreateObject("Scripting.Dictionary"): j = 1
With d
.CompareMode = 1
For i = 2 To UBound(x)
If Not .Exists(x(i, 2)) Then j = j + 1: .Item(x(i, 2)) = j
Next i
End With
ReDim y(1 To UBound(x, 1), 1 To j): j = 1
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For i = 2 To UBound(x)
k = d.Item(x(i, 2))
If .Exists(x(i, 1)) Then
n = .Item(x(i, 1)): y(n, k) = Left(x(i, 3), 1)
Else
j = j + 1: .Item(x(i, 1)) = j
y(j, 1) = x(i, 1): y(j, k) = Left(x(i, 3), 1)
End If
Next i
End With
With Sheets("Report")
.UsedRange.ClearContents
.Range("A2").Resize(j, d.Count + 1).Value = y: .Range("A2") = "Name"
.Range("B2").Resize(, d.Count).Value = d.keys: .Activate
End With
Set d = Nothing
End Sub
Bookmarks