Automation Anywhere Enterprise For Loop in excel file

Piotr picture Piotr · Mar 27, 2018 · Viewed 11.4k times · Source

I'm learning AAE for like a week and I have problem with for loop in excel file. I have prepared table with Vendor Id, Material, and order Quantity:

Vendor  Material    Quantity
25000   1545454      100
64003   7854786     1024
25000   5896471      250
25000   3336661      900
64003   7854786     2048
25000   3336691      900

And I wanted to validate table if there is any redundancy in material and vendor column. I have created 6 variable 2 for each column and named them : POv, POm, POq and Vpo, Mpo, Qpo. And of course 2 itterators Itteraor2 and Itterator3 that I am incremanting in 2 loops.

enter image description here

Problem is that my loop is infinite, while I wanted only to itterate 6 times (number of rows) and additionally it is messaging me that row 2 AND 3 has the same vendor ID and material ID what is not true. Could somebody tell me what is wrong and how to fix it ?

Answer

Clint picture Clint · Mar 28, 2018

Few corrections in the code:

First:

For the inner loop, consider placing the variable operation between End If and End Loop.

Second:

For the outer loop (before$iterator3$+1), ensure that the inner loop counter is set like this

$iterator2$= $iterator3$+1 so that it does not compare the previous rows again.

P.S: Avoid using any absolute(C:\Users\xxx\yyy.xlsx) path name for opening files/spreadsheet instead use the System variable $AAApplicationPath$ this will help you to deploy the bot from a Control room to a Bot Runner