Group Similar data which are dynamic

how to group same values in excel

eg;

col1

apple
apple
banana
banana
apple
orange

need all apples in separate sheet, similary orange banana etc…

the thing is the column value keeps on changing with each excel.

next excel can be

peach
peach
strawberry
strawberry
peach

etc…

How to achieve this without for looping??

@amithvs

Try like this:

applet = DatatableName.Select(“Col1 = ‘apple’”).CopyToDataTable

But “apple” is not fixed… it keeps on changing

@amithvs
I am not sure I got you in all.
Excel 2:
peach
peach
strawberry
strawberry
peach

And the expected result is a new excel with:
Workheet: peach
Rows: Row1, Col1 =peach, Row2, Col1 =peach, Row3, Col1 =peach
Worksheet: strawberry
Rows: Row1, Col1 =strawberry, Row2, Col1 =strawberry

Is this your requirement?

1 Like

Yes, but the fruit name keeps on changing…sometimes it can be watermelon that is having 10 info…so need to create a sheet for watermelon and put all watermelon in that sheet.

Even if the data is one it should be segregated and placed into a new sheet with its name.

i developed this by using for loop and filter data table activity…But its very time consuming.

@amithvs
Give a try:
readin excel in a datatable (Read Range)
Create a list from distinct fruit names (LINQ/DataSetExtensions Distinct Method helps for this)
Iterate over the list with distinct fruit names
inside the iteration:

  • use fruitname to collect all information for this fruitname
  • write these information back in a new worksheet
1 Like

I will give a try.

@amithvs
Try this if the value is changing
DataTableName.Select(“[col1]='”+Value+“'”).CopyToDataTable

Here Value is a string variable, you can pass your filter value

@amithvs
In the case of you need some further help then please also post for 2 scenarios an input sample and an output sample (e.g. *.xlsx) along with your question.

Happy Coding

Upload.xlsx (12.6 KB)

Hi, here is the input file. Sorry for the late reply.

But this +value+ is not fixed. So need to include the for loop item as +value+ ??