For Each Loop does not stop


I have taken a column of Excel and put it in the List variable.
I have used the command for each “item” in “list” to iterate through the loop.
Irrespective of reaching the last item on the list, the loop does not exit.
This leads to an infinite loop.


Hi, please provide full code, do you have expirience working with coding ?


@Sohana_kamat - see this topic - While loop does not stop

You can use the Trim text action to remove white space -


I want to loop through a list so while may not be that helpful as we cannot iterate through the list using the variable “item”.
Below is the image of my code.

@ahlushkou yes, I have experience in coding.

I am picking data from a column from the excel and putting it into a list.I am using the for each loop to iterate through the list.
I am checking when the "item’ value is “END”, I want to stop the iteration.

I want to use the command “For Each (item) in the (list) List”

Kindly advise.


@Sohana_kamat - why do you use While loop (86) inside the For Each ?

I suggest you the following solution:

  1. Create an empty list
  2. Open Excel
  3. Create a loop inside Excel which pushes (appends) current cell value to your list IF the cell value IS NOT equal to “END”
  4. Create For Each loop for your list. (item variable will contain the current list element on each iteration)