How do you (the human) decide which range to loop?
This might help: How to mark a row in a CSV line as processed?