Для целей этого ответа данные, включенные в Лист1 и отдельные в Группы в Листе 2.
Попробуйте:
Option Explicit
Sub test()
Dim LR As Long
Dim GroupName As String
Dim LC As Long
Dim i As Long
Dim j As Long
Dim LC2 As Long
Dim LR2 As Long
Dim Exist As Boolean
LC = Sheet2.Cells(1, Sheet2.Columns.Count).End(xlToLeft).Column
LR = Sheet1.Cells(Sheet1.Rows.Count, "A").End(xlUp).Row
For i = 2 To LR
Exist = True
GroupName = Sheet1.Cells(i, 1).Value
If LC = 1 And Sheet2.Cells(1, 1).Value = "" Then
Sheet2.Cells(1, 1).Value = GroupName
Sheet2.Cells(1, 1).Offset(2, 0).Value = Sheet1.Cells(i, 2).Value
Else
LC2 = Sheet2.Cells(1, Sheet2.Columns.Count).End(xlToLeft).Column
For j = 1 To LC2
If GroupName = Sheet2.Cells(1, j).Value Then
LR2 = Sheet2.Cells(Rows.Count, j).End(xlUp).Row
Sheet2.Cells(LR2 + 1, j).Value = Sheet1.Cells(i, 2).Value
Exist = True
Exit For
Else
Exist = False
End If
Next j
If Exist = False Then
Sheet2.Cells(1, LC2 + 1).Value = GroupName
Sheet2.Cells(1, LC2 + 1).Offset(2, 0).Value = Sheet1.Cells(i, 2).Value
End If
End If
Next i
End Sub