Very easy with Power Query
, available in Excel 2010+
In this case, all can be done from the User Interface.
- Select some cell in the table
- Data --> Get & Transform --> From Table/Range
- Select the
Parent Product
and Product
columns and Group By

- Add Custom Column
- Formula:
=Table.Column([Grouped],"Sequence")
- New Column Name:
Sequence

- Select the double headed arrow at the top of the Sequence Column
- Extract values with comma separated
- Delete the extra columns and rearrange.

M-Code
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent Product", type text}, {"Sequence", type any}, {"Product", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Parent Product", "Product"}, {{"Grouped", each _, type table [Parent Product=text, Sequence=anynonnull, Product=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Sequence", each Table.Column([Grouped],"Sequence")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Sequence", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Reordered Columns" = Table.ReorderColumns(#"Extracted Values",{"Parent Product", "Sequence", "Product", "Grouped"}),
#"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Grouped"})
in
#"Removed Columns"