CurrentRow - How to get the row number?

I would like to use this value vs doing what I did right now which was to create my own variable to increment it. I can get the all the data from that variable but the actual row number and its been driving me nuts.

If you’re trying to get the data from the current row, you just use CurrentRow(“column name”).ToString

You don’t need the row index.

To get the row index use the index property of For Each Row in Datatable.

Hi @nicholas.lewis

Could you elaborate your query, then we will get understand of it

I don’t need the value of any one cell, as I am trying to copy a sub range of the data. I just need to know what row it is currently on.

To know about that create a RowCount variable which is Int datatype, before the for each activity and initialize the variable with 1.
Inside for each after all activities take an assign activity and increment the RowCount.

Where you want to use that RowCount Variable you can use it.

Hope it helps!!

I already stated this is what I am doing, but surely this is overkill. You are telling me the CurrentRow doesn’t hold a method for pulling out the current row value?

No there is no method to pull the row count from the currentRow.

Follow the above method that will be more helpful to get the row count.

Hope you understand!!


CurrentIndex will return the row value being evaluated while doing a for each excel row.

No the currentIndex value returns the index value of the row you have to add 2 for it then you will get the row count in for each excel row.

- Assign -> CurrentRowCount = currrentIndex+2

Hope you understand!!

As I said in my first reply…

I didn’t need to do this, CurrentIndex was perfectly exactly what I required. I did a ‘write line’ to make sure. I also didn’t need to assign or do anything fancy. I was trying to work directly with the variable to avoid having to create and use yet another variable.


How many rows do you have in the excel by excluding header and what is your output by CurrentIndex. @nicholas.lewis

Row 1 - Headers
Row 97 - last row of column “A” with data
I used find First/Last Row data to get this. I did have to alter the First row variable to reduce it by 1 as when you have headers it skips this and assigns start as row 2. This through me off for quite sometime.

I didn’t asked you about the Find First\Last row activity it will give the first row and last row number, I know… @nicholas.lewis

But I want to get the what is the row number of last row and what is index of it.

Hope you understand!!

97 / 97

it counted 1 to 97 as expected.

Okay, now I am seeing the issue with CurrentIndex, if you tell the system to skip say blank lines then the CurrentIndex will be off. I really expected to have something like get activecell.row but that might be something I can get when I move up to Studio vs StudioX.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.