Group by state data

Hello friends,
I have a customer data in which der z a column name called “state” however my task is to segregate different states data in different excel sheet !
Plz help

Hi,

In this case, LINQ GroupBy and ToDictionary will help you.

dict = dt.AsEnumerable.GroupBy(Function(r) r("state").ToString).ToDictionary(Function(g) g.Key,Function(g) g.CopyToDataTable)

note: dict is Dictionary<string,DataTable> type

Sample20230320-2L.zip (3.0 KB)

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.