Name

listrow.Range

Synopsis

Returns a reference to the Range object for a row in the list. Use the Range property to get the values and address of items in a list. For example, the following code creates a new row and sets the values of the second, third, and fourth items in the row:

Sub SetValues(  )
    Dim ws As Worksheet, lst As ListObject, row As ListRow
    Set ws = ActiveSheet
    Set lst = ws.ListObjects("Test List")
    lst.ListRows.Add (2)
    lst.ListRows(2).Range.Cells(1, 2).Value = "a"
    lst.ListRows(2).Range.Cells(1, 3).Value = "b"
    lst.ListRows(2).Range.Cells(1, 4).Value = "c"
    lst.ListRows(2).Range.Cells(1, 5).Value = "d"
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.