cancel
Showing results for 
Search instead for 
Did you mean: 

How to get an active row index value while running a loop? If any VBO supports this function I wanted to know.

How to get an active row index value while running a loop? If any VBO supports this function I wanted to know.

For e.g., If the loop is running on the 3rd-row index should return 3 as the index.

------------------------------
Thanks & Regards,
Tejaskumar Darji
Sr. RPA Consultant-Automation Developer
------------------------------
4 REPLIES 4

ritansh.jatwani
Level 9
Hi @Tejaskumar_Darji,

​You can use a counter variable which gets incremented every time when you are looping through the records. This will keep a track of the row index.

------------------------------
Ritansh Jatwani Senior Consultant
Consultant
EY
Gurgaon
------------------------------

This makes sense.

------------------------------
Murali Krishna
RPA Consultant
------------------------------

Yes, that is the all-time best option but we don't have any such alternative where we can get index directly from loop where I won't use such counter mechanism instead I can get index on any row when required.

------------------------------
Thanks & Regards,
Tejaskumar Darji
Sr. RPA Consultant-Automation Developer
------------------------------

I don't know of any way to do this, but it would be very useful. Could be a good idea to suggest.

Some workarounds I've done before are (1) obviously a counter variable that is incremented as you loop which you already know about and (2) create a new column, and insert a one-up number into each row (1, 2, 3, 4, etc.). For #2, it works well​, but you have to take the time to insert the new column and numbers before working with it, and then you typically need to remove the column later on as well.

If you're taking the data from excel, then it might be a bit easier to create a column there with one-up numbers in that column to represent the index numbers.

------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company