Get last column with row value

Hi , I need to get the last column with row value . In the below image i need G5. Please help me on this

Last column can be found with the following formula: YourDataTable.Columns.Count (NOTE: I am not counting column index, because for this next portion to work you want column 1 = column A)

Use the information found in this post to convert that from a number into a letter: Get last column of Excel sheet in Alphanumeric form

To get the first row with data the easiest way is likely to use a for each loop to check if row.item(YourColumnIndex).ToString = string.empty. Then add 1 to that row index (since datatable index starts at 0, but excel index starts at 1) and the output in the end should be G5

I have used the read row activity + the Roboyo IntToExcelColumn activity (found on the marketplace) for such a use case. Mine was a bit more complicated because it was finding the last matching date within a row (like yours but with future months as well), so i reversed the output from the ReadRow activity and iterated through it. If you wanted the last column only you could take the ReadRow activity output, use Count on it, add 1, and use the IntToExcelColumn activity to get the column letter like @Dave suggested.

Hi @deepak_raj,

Here is an activity called “Find last column” to find the last column index.

Video demo :


1 Like

Are you able to go to last cell with data in a specified column?

HI @RPA_Opportunity,

yes. you can.

  • Use the Find Last Row No. It will return the last row index.
  • Use the Find Last column index. it will return the last column name.
  • Finally, combine the column and row index. It will be the last cell.

Thank you