For each row loop return row number

kinda embarrassed to ask this … and I know the answer is something really simple

when, I’m looping through, how do I return the current row number ?

(I know I could create a int and just count that but there must be an inbuilt variable?)

@hughabbott - You mean cell address ? like A22, B15 etc…

Hi @hughabbott
There is an index property in for each row which returns the row index of current row

could you give me an example.

row.index or something like that ?

actually, I thinking about a “For Each Row” activity.

If I wanted to have a message box tell me which row is the current row number … how might I get that ?

Hi @hughabbott
Check this workflow
Main.xaml (7.5 KB)


Nived N

Happy Automation

Nived - I wonder if you might type in the line of code ( I could not open the xaml file because of a version conflict )

thanks for your help thusfar.


Hi @hughabbott

Here index variable is created in index property of for each row

Please Note


Nived N

Happy Automation

Hello if the intention is to discover an excel line to write in it, I use the following method.

The activity (LookUp Range) does a search in excel for something of your criteria, a text for example, and returns the cell, except for A5, then you save it in a Var.

To write in excel in C5 for example.
Use Write Cell, and as input Var.Replace(“A”, “C”)

Write in the cell, in the line with the value found, but in column C.


Main.xaml (10.2 KB) teste.xlsx (9.1 KB)

1 Like

I wonder what I am doing wrong ?

Can u show the property panel of match address?

hmmm I think i understand now

I get it now … I thought the there was some kind of reserved word for index, I did not know you set it each time to your own variable.

I knew it was a very basic error … now I get it.

sorry for being stupid :slight_smile: !

and thanks for your help

1 Like

You can get index of a particular row using below code, @hughabbott
Integer_Value = DataTable.Rows.IndexOf(row) and DataTable will be same which you pass to the For Each Row Activity.
Hope this may help you :slight_smile:


I found this very helpful. It’s working.

1 Like