Where am i wrong? While loop activity

I am doing a project where i develop a robot to help me insert information into a web browser. However i do have a problem with my robot, and i hope someone is willing to help me solve this problem. I am using the robot to read a cvs file and insert it into excel and using the excel data to input data in a web browser. My problem is the data i have from my excel sheet does not get inserted the correct way into the web browser. It does put in the right values into the right boxes, but the problem is that it does not go through my excel data, but simply inserts the data from the last column 3 times.(The number of columns in my excel). it does not go from column 1 to column 2 to column 3 etc. Is something wrong with my “while” activity? Note that the output from the excel file is called “output”.

Have you attempted to troubleshoot if the rowNumber variable is being incremented the way you expect it to? Place a write line rowNumber.tostring after the increment step and track it.

Is it starting at 1 and moving to 3 then the sequence exits the while loop? Thats what you want it to do right?

Either there is an issue with the initialisation of the rowNumber (it needs to be reset to zero before the while loop is invoked) or the increment step is seeing an issue. Post up more details once you have done that.

Thank you for the reply.

That is exactly what i want it to do.
I have tried to do what you explained.


It seems like it does go from 1 to 3… However i do not understand why it only writes the last line in my web browser then.

It does only insert the fourth column, but three times.

Ok, so the issue is not the functioning of the while loop. It is working fine.

The issue is with your Read and Write activities for the AccountNumber. Where is this being performed in your workflow? It doesn’t seem to be part of your while loop


if Possible please share variable assign activity screen shot, i think issue in assign activity to variable from excel data row.


I use the activity “for each row” and “get row item” within the activity for the columns… (It is not in the while loop activity but before). Capture


If possible please share workflow file .


Ok, well that is why it is writing it three times. The AccountNumber variable never changes as the workflow enters the While loop. The bot subsquently writes it three times. Your process logic needs refined.

Do you even need a while loop? Why not carry out the process of writing the data inside your For Each Row loop? That way it is carrying out the process three times but with varying data, as you need it to.


The best way to accomplish the task will be to move the code within the while loop into the for each row loop.

The references to the column values can be made with the variablename(coulmnname).ToString


ForEach row in VarDataTable

Type Into

I have used the while loop so i could use the condition rowNumber < output.Rows.Count. But that might not be necessary?

Another reason i have used the get row item where i give the row item a variable name, is that I, at some point, need the variables for a flow chart…

The ForEach loop will take care of the looping. So the additional while loop is not necessary.

Thank you very much. It is working now!

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