I need to remove duplicates based on Name, Number and Friend column.
Once the duplicate rows are removed, Concatenate the Friend and Description column into 1 row for the unique Name Column.
(From row In DT.AsEnumerable()
Group row By Name = row.Field(Of String)("Name"), Number = row.Field(Of Double)("Number")
Into Group
Select DT.Clone.Rows.Add(Name, Number,
String.Join(",", Group.Select(Function(r) r.Field(Of String)("Friend")).Distinct()),
String.Join(",", Group.Select(Function(r) r.Field(Of String)("Description"))))).CopyToDataTable()
uniqueRows = From row In dtInput.AsEnumerable()
Group row By Name = row("Name"), Number = row("Number") Into Group
Select dtInput.NewRow() With {
.Item("Name") = Name,
.Item("Number") = Number,
.Item("Friend") = String.Join(",", Group.Select(Function(r) r("Friend").ToString()).Distinct()),
.Item("Description") = String.Join(",", Group.Select(Function(r) r("Description").ToString()).Distinct())
}
Assign activity to initialize the output DataTable:
dtOutput = dtInput.Clone()
For Each activity to loop through uniqueRows and add them to dtOutput:
For Each row In uniqueRows
dtOutput.Rows.Add(row.ItemArray)
Next
Write Range activity to write dtOutput to an Excel file.