Class ListRow (Excel VBA)
The class ListRow represents a row in a table. The ListRow object is a member of the ListRows collection.
Set
To use a ListRow class variable it first needs to be instantiated, for example
Dim lstobj As ListObject: Set lstobj =
Dim lstrw As ListRow
Set lstrw = lstobj.ListRows.Add()
The following procedures can be used to set variables of type ListRow: ListRows.Item, ListRows.Add and ListObject.ListRows
For Each
Here is an example of processing the ListRow items in a collection.
Dim lstobj As ListObject: Set lstobj =
Dim lstrwListRow As ListRow
For Each lstrwListRow In lstobj.ListRows
Next lstrwListRow
Delete
Deletes the cells of the list row and shifts upward any remaining cells below the deleted row. You can delete rows in the list even when the list is linked to a SharePoint site. The list on the SharePoint site will not be updated, however, until you synchronize your changes.
Index
Returns a Long value that represents the index number of the ListRow object within the ListRows collection.
Parent
Returns the parent object for the specified object. Read-only.
Range
Returns a Range object that represents the range to which the specified list object in the list applies.
ListRows.Add
Adds a new row to the table represented by the specified ListObject.
If Position is not specified, a new bottom row is added. If AlwaysInsert is not specified, the cells below the table will be shifted down one row (same as specifying True).
Syntax : expression.Add (Position, AlwaysInsert)
Set myNewRow = ActiveWorkbook.Worksheets(1).ListObject(1).ListRows.Add
Arguments
The following arguments are optional
Position (Integer) - Specifies the relative position of the new row.
AlwaysInsert (Boolean) - Specifies whether to always shift data in cells below the last row of the table when the new row is inserted, regardless if the row below the table is empty. If True, the cells below the table will be shifted down one row. If False, if the row below the table is empty, the table will expand to occupy that row without shifting cells below it, but if the row below the table contains data, those cells will be shifted down when the new row is inserted.
ListRows.Count
Returns an Integer value that represents the number of objects in the collection.
ListRows.Item
Returns a single object from a collection.
Syntax : expression.Item (Index)
Index: The name or index number of the object.
ListRows.Parent
Returns the parent object for the specified object. Read-only.