How to update a colunm inside "For Each Row"

Hi guys,i will explain my problem.

I have a datatable wich its used in For Each Row, the datatable has 3 columns and i want to change third column of a cell each time.

foreach

so i put this assign :
TablaconData.Rows(2).Item(“Procesado”) = “asdsa” +num1

“Procesado” its the name of the column.

assign

all ok but only update the last cell.

or maybe you have another way to update cells each time of the For each Row.

Please Help… :frowning: :frowning:

Hi,

I guess you need to set row("Procesado") = "adsad"+Num1 in the for each row loop, then set Write Range activity after the loop.

Regards,

1 Like

@Julio_Mendoza Instead of using TablaconData.Rows(2).Item(“Procesado”) = “asdsa” +num1
use row.Item(“Procesado”) = “asdsa” +num1
because in your expression you are only updating the value of 2nd row index i.e. 3rd row

1 Like

ohhhhh thats right, mmm… so how can i update third value each time?

there is way to get the current index to set a value or something like that?
:frowning:

@Arpit_Kesharwani mentioned how do to that already in his replies. If you use TablaconData.Rows(2).item(“Procesado”) then you are selecting the datatable named ‘TablaconData’. Then you are selecting the 3rd row in that datatable, then you are selecting the column named ‘Procesado’ .

However, the way @Arpit_Kesharwani mentioned will work. You are already iterating through each row. Therefore if you just reference row.item(“procesado”) then you will be on the correct datarow - no need to get the current index. Just use an assign activity and type row.Item(“Procesado”) = “asdsa” +num1

Then after the for each loop is finished (outside of the for each loop) you should use a write range activity to write the datatable with the updated values back to excel

1 Like

thank you very much guys, with your help i descover 2 ways(solutions).

First: TablaconData.Rows(cont).Item(“Procesado”)
i create a variable cont as a counter and then at the end of foreach i added 1 to the variable and it works.

Second: row.Item(“Procesado”)
its more efficient

thanks to everyone again!!! :3

1 Like

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