Excel read cell value, address as A:Last populated row variable?

Hi Guys,

Need to get the value in the last populated row in column A, whole numbers.
Using find first / last data row and getting the last populated row, this row count will increase as time goes by…

Lets say the var for last pop row is Last_Pop_Row

Hard coded…Excel.Sheet(“Table1”).Cell(“A7”)

I tried the following but no go…Excel.Sheet(“Table1”).Cell(“A&Last_Pop_Row”)

I thought about reading into a datatabe then sort column high to low ?
Thoughts or another way ?

Thanks guys :grinning:

Screenshot 2023-02-16 193444

@MikeC

I beleive Last_Pop_Row is the last row index. please try like this

Excel.Sheet(“Table1”).Cell(“A”+Last_Pop_Row)

Or read the data into datatable then us
Dt.Rows(dt.Rowcount-1)(0).ToString

Cheers

Cheers

1 Like

Just read the whole thing into a datatable with Read Range, and then get the value from the last row of the datatable.

1 Like

Hi Paul,

Worked a treat, pain in the arse getting the syntax though :joy:

Dt_accountnums.Rows(Dt_accountnums.Rows.Count-1)(0).ToString

Thank you :ok_hand:

Hi Anil,

I didnt get an error, just a blank output…
Paul came up with a solution.
Leave it at that or try the excel route again ?

Thank you :grinning:

Mike

@MikeC

Happy automation. That is what i quotes above

Cheers

1 Like

:joy: :joy: :joy: :joy: :joy:

Sorry Anil, was concentrating on youre Excel suggestion and completely missed the dt suggestion.
You were right, my bad :roll_eyes:

Thank you :grinning:

1 Like

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