lastrow and excel table.

后端 未结 4 1325
失恋的感觉
失恋的感觉 2020-12-06 08:23

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

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 09:13

    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
    

提交回复
热议问题