Grouping of Data in Excel

Hello Everyone,

I want Group Data in excel Based on value in one of the column and Give the number for Each group.


Expected Output:

I know this can be done by using loops. But i am Expecting better method. I hope for better solution soon.

Hi @Manjuts90,
You may try to Invoke VBA.

1 Like

you can achieve it by using linq queries using group functions

1 Like

@shyamm Can you provide link query for it, if possible?

I dont No More About Linq
i can provide small solution it will decrease little bit execution time

1.Use below linq query in assign to get the district values fro data table into list variable or array of string (From row In dt.AsEnumerable() Select(Convert.ToString(row(β€œName”)))).Distinct().ToArray()
2.use for each and in for each body use select query to get the duplicate names into single datatable dt.Select("[Name] = β€˜"+item+"’ ").CopyToDataTable write in excel


@shyamm Thanks for your suggestion bro, i already did that mention same thing in my post.


This was really helpful! Thank you so much!