Find row number for excel

Hello Expertise
Please can you guys help me on how to find the last updated row number of the sheet. Please view the image below for better understandingrow

i)If you are using Read Range activity to read excel into datatable(with headers) then last row number

1 Like

in case I do not want to read the sheet content in order to get the row count (as advised @Naveen_tg) I write a temporary “row count” formula into the first row and after getting the row count I remove it again.



1 Like

Please use Read Range Activity. The output will be in Data table say DT1.

To find the last row, then lastRow = DT1.Rows.Count
To find the next available row, then availRow = lastRow + 1

Karthik Byggari

1 Like

You’ve already gotten some answers that should help you. However, if not, I’d like to know whether it is the BOT which is updating the rows of this excel sheet one by one when you say “the last updated row number”. If that is the case, then it means you must be using a “for-each” or a while loop, and every time you loop, you add another row to the table. In such a scenario, create a variable (say int intRowNumber=0;) and every time the loop gets executed and a row gets added, increment its value by 1.

If you’re using a for each, you don’t even need to increment the value of the variable. Just put the variable in the “Index” property of the for-each:

In this case, since intRowNumber represents the row index, the row number for each updated row will be (intRowNumber+1)


1 Like

Thank you.
But will it work same in google spreadsheet.

Can you please show me some demo, I am not getting it.

When I try this in google spreadsheet the value availRow show the lastRow? Can you tell me why is that so?

When you read the data, you might checked the option “Include Headers”.
So in this case, data table doesn’t contain the header row in the data table.
So in this case, lastAvailRow will be DataTable.Rows.Count + 2

Karthik Byggari

1 Like

Why don’t you share your workflow here for others to look into it?

Thank you for your help.

1 Like

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