How to Find the End Row of Specific Column (F) in Excel using UiPath

image

Hi @ravidayalkumar

If you are sure that there wont be any blank rows in between the data, then you can actually read the excel column and remove blank rows and check the count of the rows.

One approach would be to use a little .net to filter by the column where it does not equal empty string, then take the index of the last row from the array of rows that is created.

So inside Write Line you can put this to test:
( dt1.Rows.IndexOf( dt1.AsEnumerable.Where(Function(r) r("Fri").ToString.Trim <> "").ToArray.Last ) + 2 ).ToString

where dt1 is the data table that you stored from a Read Range of the entire data.
The .Where() will return an array of rows, then by using .Last you can get the row that equals “25”.
IndexOf() finally will take the index and should equal 4, so you need a +2 to get row #6

Regards.

7 Likes

Thanks Bro, you are Awesome. It’s working and you saved my day:-)
But I didn’t expect finding Endrow in uipath is this much complicated.

Cells(rows.count,ColumnNo).End(xlup).row

I’m using this method in VBA to find the endrow in excel
Finding end row is very easy in vba

it is simply impossible to cover absolutely all cases… that is why it allows you to invoke .net, .ps code etc to solve all your issues.

No problem. You can also explore using Invoke VBA activity to execute some of the vb code that you are used to using in Excel vba. To use Invoke VBA, I would normally create a .vbs text file with vbscript and call specific sub functions.

EDIT: you can call the activity inside an Excel Scope and it will run on that file in the scope

2 Likes

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