# JavaScript equivalent of finding the last row



## wilsojoh (Aug 31, 2020)

Is there a JavaScript equivalent of the VBA method to find the last row?

finalRow = cells(rows.count, 1).End(xlUp).row


----------



## VBE313 (Sep 1, 2020)

Yes there is.


```
const ws = context.workbook.worksheets.getItem("Sheet1");
let getLastCell = ws    
      .getCell(0, 1)
      .getEntireColumn()
      .getUsedRange(true)
      .getLastCell()
```

by setting getUsedRange to true, it will grab the last cell that has a value in it.


----------



## wilsojoh (Sep 1, 2020)

VBE313 said:


> Yes there is.
> 
> 
> ```
> ...


Thank you. I use the find last row all the time as I mainly deal in consistent data frames.


----------



## VBE313 (Sep 2, 2020)

wilsojoh said:


> Thank you. I use the find last row all the time as I mainly deal in consistent data frames.


you are welcome. I have been playing around with the new Excel TypeScript macros. They are fun but definitely have a learning curve.


----------

