Foreach Loop keeps failing

A For loop version of this code works just fine.

What’s the problem.

I notice you’re setting LocalIndex twice, probably doesn’t matter. Might also be an idea to clear the bool before your start the loop. I seem to recall problems with local vars not initializing.

I’ve noticed recently that if the array from the Foreach Loop is equal to -1 then the Foreach Loop will not run a single time. maybe that’s your problem?

I know you said it works with a For Loop, but just to double check,

You have the row name = empty. In order for that to work, the name variable has to have the literal text of Empty. Do you have that set up that way or is it the default of None?