I’m facing an issue when trying to get the last row of an Excel file. Due to the size of the file and the fact that the columns aren’t always the same, the read range activity isn’t an option. Also the find last row activity doesn’t work.
As a workaround I’ve got a piece of VBA code to determinatet he last row of the file:
Dim lastRow as Long
lastRow = Sheets(“Open lines”).Range(“K” & Rows.Count).End(xlUp).Row
In the Invoke VBA activity I aad a variable for the output:
This output is automatically created as an Object variable. The issue is that I can’t manage to read this value as it returns just blank (no value):
Here, replace “A” with the column letter of the column you want to find the last row number for.
This formula works by finding the maximum row number for cells that are not empty in the specified column. The INDEX function returns the value of the cell at that row number, and the ROW function returns the row number of that cell. This gives you the last row number of data in the specified column.
The problem on using it as data table is the difference in the amount of data as it’s not structured.
So the process can sometimes read range but it’s not a robustic solution as it also tends to fail.
The solution then would be to get the data without using the read range activity. But here is where I’m facing the issue. And since I have multiple files (about 500) it wouldn’t be a smooth solution to link all the files to Excel.