For Each Row: Collection was modified; enumeration operation might not execute

My first question is : Why do i get this message as in the topic? Please explain it in a easy way.

My second question is: How can i fix this. Please look at the picture below.

1 Like

Hi @Anders_Dahl1,

It’s simple pass any excel path and get the output as DataT1 and to write the data on it you are using Add data row pass any string as an array of strings and pass the final path in write range.

Cheers

1 Like

Hi @Pradeep_Shiv,

In my Read Range i have “DataT1” as output. So that is a DataTable

In my Add Data Row, It look like the picture below

image

And in the Write Range it look like in the picture below.

image

1 Like

Pass the workbook path same in destination (Write range)

1 Like

I have the same path in both Read Range and Write Range.

And still get that message,

1 Like

image

I’ve just passed outDt from read range as input to the Write range and passed the exact path.

You can just try this!
Cheers

1 Like

That worked fine!

1 Like

@Anders_Dahl1

Use Read Range with Excel file path correctly

Instead of Foreach Row and Add DataRow, you can use write Range activity to always remove the existing data and Append Range to append to existing data

Hope this helps you

Thanks

2 Likes

Can i use this with a “IF” condition as well?
I want to check a row to see if a specific column is empty and do something with it?

@Anders_Dahl1

Yes, but using For Each Row, check below for your reference

https://forum.uipath.com/t/tutorial-how-to-calculate-difference-between-two-time-values-using-uipath/247565/3

Hope this helps you

Thanks

1 Like

Hi @Anders_Dahl1

Instead of using workbook activitiy u can use excel activitiy and use excel application scope where u can provide excel file path (since it is same as u specified) and read and write range of excel activity with sheet names specified

Hope it helps you

Regards.
Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed: