I have tried to define a lastrow code that would return the last row value of the last non empty cell in a excel table. (ITS FORMATTED AS A TABLE)
My exceltable have
Try the code below to get the last row in Column A and Column B from a Table (ListObject
):
Option Explicit
Sub LastRowTable()
Dim Tbl As ListObject
Dim LastRow2 As Long, LastRow3 As Long
' modify "Table1" to your table's Name
Set Tbl = ThisWorkbook.Worksheets("DataÖnskemål").ListObjects("Table1")
LastRow3 = Tbl.ListColumns(1).Range.Rows.Count '<-- last row in Column A in your Table
LastRow2 = Tbl.ListColumns(2).Range(LastRow3, 1).End(xlUp).Row '<-- last row with data in Column B in your Table
End Sub