How to add data to an existing data table using for each loop

Any one please help me to add data to a data table using add data row activity inside a for each row because I am getting below error while doing this.

For Each Row in Data Table: Collection was modified; enumeration operation might not execute.

Thanks in advance

Hi @mukesh_behera

Please refer this file. (3.0 KB)

it looks from error like you are iterating over the same datatable on which you are adding new rows.

As the error states: this is not possible as the sequence used for looping is modified after adding a new row / remove a row

Maybe you can give us some more details to your flow that we can give you some suggestions. Thanks

Yes I am trying to add data row at the same time while i am reading . How to do that

please share some details with us on what is to achieve / the current flow

My issue is to filter a excel where some rows are same

And store that in a another sheet

so you have duplicates in dt1 (2cols=AllCols are to check)
Your would like to do following:

  • detect all duplcated rows in dt1
  • add all duplicated rows to dt2

Anything else to do?

Delete duplicate rows and only unique rows to store in a other sheet

Waiting for your response

Have a look on this starter help, taking 2 cols for Duplication check and show cases on how to retrieve all Dups, Non Dups and first from Dups:
FindDupsUniquesFirstFromGroup_By2Cols.xaml (12.4 KB)

so we would recommend:
use first from dups approach for the other Worksheet
use non dups for the duplicate removal