lastrow and excel table.

You will have issue if there is data below the excel table on the sheet. It’s always better to refer the table column while finding the last row in an excel table.

Sub FindLastRowInExcelTableColAandB()
Dim lastRow1 As Long, lastRow2 As Long
Dim ws As Worksheet
Set ws = Sheets("DataÖnskemål")
'Assuming the name of the table is "Table1"
lastRow1 = ws.ListObjects("Table1").Range.Columns(1).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
lastRow2 = ws.ListObjects("Table1").Range.Columns(2).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
End Sub

Leave a Comment