简体   繁体   中英

Excel VBA refer to Table name insert data after last row

I am trying to find a simple way to refer to the NAME of a formatted table and insert data after the last row of the table I am referring to

Currently I am referring to a column - but I want to make it with the name of the table

Sub lastrow()
    Dim Last1 As Long

    With ThisWorkbook.Sheets("sheet2")
        Last1 = .Cells(.Rows.Count, "B").End(xlUp).Row
    End With
End Sub

Here's how to add a new row to a table/listobject

Dim rng as Range
Set rng = ThisWorkbook.Sheets("sheet2").listobjects("tableNameHere").ListRows.Add().Range

'work with rng, which is the newly-added row

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM