So if you need only the count of eqch group the. Use the below linq…which will give you a two column table one with your key and other with count…you can build a datatable with 2 columns and use the belao in assign
Newdt = (From d In Dt.AsEnumerable() Group d By k=d("key").toString.Trim Into grp = Group Let coun = grp.count Let ra = New Object(){k,coun} Select r = Newdt.Rows.Add(ra)).CopyToDataTable()
If you want each of the group only as separate sheets or anything then
Use a assign with uniquedt = dt.DefaultView.ToTable(True,"key") - this will give to the unique values from key column
Now use for eqch row in datatable on uniquedt
Inside the loop use filter datatable and filter the original dt on key column with currentrow(0).ToString - for each iteration one group will be filtered which you can write to excel in different sheets or append or use merge datatable and create a merged table again
(From d In nuevooDT.AsEnumerable() Group d By k=d(“key”).toString.Trim Into grp = Group Let coun = grp.count let xSum=grp.Sum(Function(x) Cdbl(x(“count”).ToString.Trim)) Let ra = New Object(){k,coun,xSum} Select r = Newdt.Rows.Add(ra)).CopyToDataTable()