Getting the last row of a given column in Excel with a formula or with VBA is quite a trivial task. It is explained here quite well 🙂 However, when we come to C#, the only “trick” that is provided…
Getting the last row of a given column in Excel is easily done with a User-Defined Function in VBA:
1 2 3 4 5 |
Function LastRow(wsName As String, Optional columnToCheck As Long = 1) As Long Dim ws As Worksheet Set ws = Worksheets(wsName) LastRow = ws.Cells(ws.Rows.Count, columnToCheck).End(xlUp).Row End Function |
There are two other formulas, which would get the last used cell in a given row, depending on whether it…