Lesson 12 practice 1 - for each "row" in "valuesTable" - row variable not recognized within the loop

I do not have Microsoft Excel, so I don’t think I can use the excel specific activities within UiPath (not 100% sure about that). Instead I’m using the generic workbook activities.

Here’s my for each loop:

And here’s the error I’m receiving:

EDIT: I changed the display name of the Assign activity in the Finally block of the Try Catch segment to verify it’s the source of the error. The first screen shot doesn’t reflect that though sorry

I believe you can use Workbook activities and it should work fine even if you dont have excel activities installed.

Can you explain a bit what you are trying to achieve? Are you trying to add your result.ToString value as a new row for the valuesTable DataTable. If yes, you may want to try ‘Add Data Row’ activity for it.

Also, just to check if your DataTable valuesTable actually contains any value or now, add a message box above the for each loop with valuesTable.Row.Count.ToString. This should give you the number of row within the DataTable and help you identify where the issue actually occurs.

Let me know if it helps.

Rammohan B.

Yeah, I’m trying to do it with the generic workbook activities. I’m trying to add information to the existing rows.
It seems that yes, valuesTable is being stored properly

It should find the difference in the values of Cash In and Cash Out and print the result to the Difference column. Some of them of course will have problems because they contain letters. So the result printed will say there’s a problem.


Try using the following syntax in your Assign activity

row.item(“Difference”) = result.ToString


row.item(2) = result.ToString

Hi Martin,

I had a similar problem and your proposed approach does not solve the problem.

When I downloaded the original document (.zip file) and unzipped it into a directory, by following the approach advised in the tutorial, I can update the “Difference” column.
However, after I removed the generated data in the “Difference” column, save the file and run the robot again, it went through all the steps without throwing any exceptions. However, after the file is opened, no data was saved under the “Difference” column. Later I checked my excel editor, it is an Office 365, I suspect this could cause the problem. Any idea?

Kind regards,



I’m not sure if that will make a difference. Perhaps the write range command to insert the data table back into the original excel file is missing? It’s difficult to say for sure without examining the code you are working with. Can you upload a .zip or screenshots of the code?