Something like this scarm?
Sub HSV()
Dim n As Integer, old As Variant, tel1 As Integer, i As Integer, place As Variant, k As Integer, code As Variant
Range("G2:K" & Cells(Rows.Count, 7).End(xlUp).Row).ClearContents
Range("A3:E" & Cells(Rows.Count, 1).End(xlUp).Row).Sort Key1:=[A3], Key2:=[B3], key3:=[C3]
Range("F1") = Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row).Rows.Count
n = Range("F1").Value
Range("G1:K1").Value = Range("A2:E2").Value
old = "!@#&$"
tel1 = 0
For i = 1 To n
place = Cells(i + 2, 1).Value & "|" & Cells(i + 2, 2).Value & "|" & Cells(i + 2, 3).Value & "|" & Cells(i + 2, 4).Value
If place <> old Then
tel1 = tel1 + 1
Cells(tel1 + 1, 7).Resize(, 4).Value = Split(place, "|")
old = place
k = 11
End If
code = Cells(i + 2, 5).Value
If Cells(tel1 + 1, k) = "" Then
Cells(tel1 + 1, k) = code
Else
Cells(tel1 + 1, k).Value = Cells(tel1 + 1, k) & " , " & code
End If
Next i
End Sub
Bookmarks