How to save variables in array to add them later into data table?


I am a rookie at UiPath. I am currently working on a scenario where I have an excel sheet and a currency exchange website. I need to take the values from excel sheet, process them through the website , collect the exchangeValue and post them back into an existing column of the excel’s datatable.(dtExchange)

I tried pushing the result of exchange transaction to a variable (exchangeValue)and then using (add data Row ) in ForEachRow loop , and( WriteRange) outside forEachRow loop.
Uipath threw an error stating:

forEach DataRow in dtExchange :Collection is modified. Ennumeration opertion might not execute.

my variable (exchangeValue) differs for every loop in ForEachRow , so i figured I need to put the variable in array/list and iterate the index of it for each loop. Later adding the array/list values (outside the loop)into specified column of datatable .- each value of array/list into each column of dtExchange

like exchangeValue{12,13,14,} in columnName((0),(1),(2)).
but sadly I do not know how to put variable in array/list and incrementing the index in forEachRow and how to push array/list values into specified column of datatable…

please help.

If you already have all rows you need then you will change its cells by using assign activities like this:
row("ColumnName") = myValue
And in the end you will use Write Range to overwrite your sheet.

1 Like

Thanks…will let you know after i try it

1 Like

Thankyou… it works like a charm

1 Like

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