If condition in for each loop with for each row

Hi there…

I have built a model that is supposed to search for given strings from an excel sheet inside an internet browser. It search, finds and downloads to the correct folder. I have made an “image exists” boolean variable so that an IF statement provides the for each to begin the search further if the correct image does not exists.

BUT, when it have search through the rows in the excel sheet as a “row.item.tostrin” the “For each” loop just contiunues. Before I putted in the “IF” statement it searched thorough all lines and jumped out of the for each and to the next assignment, but now I am stuck in the “For each” for ever…

How can I break this without using BREAK, becaus this does not work when using a IF statement inside a “For each”.


For each company, company 1,2,3 etc I want to search on x-numbers of items. When all items are searched for and downloaded it is supposed to start all over on company numer 2. I have made an IF statement when searching for the items since not all items is given for all comanies.

It works fine without the IF, but then it is no worth to me. So i need to complete the search for items wit the IF and then breake the for each and move forward.

I have read other topics, but found no solution to this.

Thanks in advance.

Hi @asvn

Could you isolate the issue and post an example project? It would help :slight_smile:

Or at least some screenshots. These are the things I wonder about:

  1. Screenshot of the Read Range activity, that loads your data into the file
  2. Screenshot of the For Each loop


thanks for the reply.

Please look at the attached screenshot. “Image exists” has a boolean variable called “BollsSkattemelding” that is used in the “IF” statement.

Could you show me the point where variable1 is created?

See attached… I dont think te variable 1 is the problem? It gets data from the sheet correct elsewhere in the workflow, but when arriving the “IF” it does not come out of the “For each” to get to the next one.


It can sometimes happen that Read Range will read many more rows than it should, I simply wanted to see your Range selection for that activity :slight_smile: If it is just two double quotes, it can be that it reads many more empty rows and then tries to do your action for those empty rows.

1 Like

Ahh… THANKS!! I have removed some lines so the time for each try would get shorter since it failed… I had not corrected the read range for the rows. Thanks for getting me to check :slight_smile:

I have tried it all… really… but to correct the read reange… never crossed my mine…:frowning:

1 Like


One more question, if I in one place gets data from collum A in excel and it only has 3 rows of data, and another place I have 7 rows of data in for example collum B. How to get it to stop on row 3 in collum A?

Say collum A(Row0) is in one “for each”, and collum B(Row1) is in another “For each”.

Range in this example will be A1:B7, and it will get data from every A row, but no data in all of them.

Thanks :slight_smile:

If you mean to only load first three rows, why not use range "A1:B4"?
It should load the following rows:

If I didn’t get it right, please clarify :slight_smile:

Another way I can think would be to load each column to a separate Data Table, with two Read Range activities. You can simply state for the first Read Range to read A1:A4 and for the other Read Range to read B1:B7, both into separate Data Tables.

Say I have company A, B and C in column 1, and search string in column 2. For each company I need to search for all seven rows.

Yes, separate data tables would be a fix, but in one of my “for each” I have to get data from both columns…

When trying to use 2 separate tables I only get this error message when arriving the second “For each” with a new “for each row” table…


You have to put your two Read Range activities right after each other. Right now the one at the bottom is never executed.
They need to follow the arrows, so:
Start → Read Range 1 → Read Range 2 → Open Browser

Great, it worked. Thanks! :slight_smile:

I was afraid I had to use the “merge data table” function - when is this necessary?

Is it any limit in how many read range I can use after each other? No I have used 2 without any trouble. Can more be nested if necessary?

I don’t think you should worry about it too much. Unless you are planning on nesting thousands of them, you should be good :slight_smile:

1 Like

Perfect, thanks :slight_smile:

Another question loginerror…

Maybe not the right string, so I can create another if you cant help me on this one. :slight_smile:

Right now everything works smoth aftoer help from you, but when arriving at the same place each time I get an error in the Google Chrome extension.

First I get error in the flow chart indicating it can not find the UI element. But when restarting it without closing Chrome it becomes clear that the error is in te communication with Chrome.

When closing the Chrome window and reopen everything works fine until it reach the same destination.

The destination for error is sevral minutes inside the for each loop and on the last element befor it is finished.