Class ListObject (Excel VBA)

The class ListObject represents a list object in the ListObjects collection.

The main procedures of class ListObject are Delete and ListObjects.Add

Set

To use a ListObject class variable it first needs to be instantiated, for example

Dim lstobj as ListObject
Set lstobj = ActiveCell.ListObject

The following procedures can be used to set variables of type ListObject: ListObjects.Item, ListObjects.Add, QueryTable.ListObject, Range.ListObject, SlicerCache.ListObject, TableObject.ListObject and Worksheet.ListObjects

For Each

Here is an example of processing the ListObject items in a collection.

Dim lstobj As ListObject
For Each lstobj In Application.ListObjects
	
Next lstobj

Themes

Some procedures in this class have been grouped together in themes and are described on separate theme pages

Display/Show with its procedures DisplayName, DisplayRightToLeft, ShowHeaders and ShowTotals
Row with its procedures HeaderRowRange, InsertRowRange, ListRows and TotalsRowRange

Methods

These are the main methods of the ListObject class

Delete - Deletes the ListObject object and clears the cell data from the worksheet.

ActiveCell.ListObject.Delete

ListObjects.Add - Creates a new list object.

Dim lstobj As ListObject
Set lstobj = ActiveSheet.ListObjects.Add

Other Methods

ExportToVisio - Exports a ListObject object to Visio.

Publish - Publishes the ListObject object to a server that is running Microsoft SharePoint Foundation.

Refresh - Retrieves the current data and schema for the list from the server that is running Microsoft SharePoint Foundation. This method can be used only with lists that are linked to a SharePoint site. If the SharePoint site is not available, calling this method returns an error.

Resize - The Resize method allows a ListObject object to be resized over a new range. No cells are inserted or moved.

Unlink - Removes the link to a Microsoft SharePoint Foundation site from a list. Returns Nothing.

Unlist - Removes the list functionality from a ListObject object. After you use this method, the range of cells that made up the list will be a regular range of data.

Properties

Active returns a Boolean value indicating whether a ListObject object on a worksheet is active—that is, whether the active cell is inside the range of the ListObject object.

AlternativeText returns or sets the descriptive (alternative) text string for the specified table.

AutoFilter filters a table using the AutoFilter feature.

Comment returns or sets the comment associated with the list object.

DataBodyRange returns a Range object that represents the range of values, excluding the header row, in a table.

ListColumns returns a ListColumns collection that represents all the columns in a ListObject object.

Name returns or sets a String value that represents the name of the ListObject object.

Parent returns the parent object for the specified object. Read-only.

QueryTable returns the QueryTable object that provides a link for the ListObject object to the list server.

Range returns a Range object that represents the range to which the specified list object in the list applies.

SharePointURL returns a String representing the URL of the SharePoint list for a given ListObject object.

ShowAutoFilter returns Boolean to indicate whether the AutoFilter will be displayed.

ShowAutoFilterDropDown true when the AutoFilter drop-down for the ListObject object is displayed.

ShowTableStyleColumnStripes returns or sets if the Column Stripes table style is used for the specified ListObject object.

ShowTableStyleFirstColumn returns or sets if the first column is formatted for the specified ListObject object.

ShowTableStyleLastColumn returns or sets if the last column is displayed for the specified ListObject object.

ShowTableStyleRowStripes returns or sets if the Row Stripes table style is used for the specified ListObject object.

Slicers returns a list of the table slicers associated with a ListObject.

Sort gets or sets the sort column or columns and sort order for the ListObject collection.

SourceType returns an XlListObjectSourceType value that represents the current source of the list.

Summary returns or sets the description associated with the alternative text string for the specified table.

TableObject returns a TableObject object.

TableStyle gets or sets the table style for the specified Listtablestyle tablestyle. Read/write Variant.

XmlMap returns an XmlMap object that represents the schema map used for the specified table.

ListObjects.Count returns an Integer value that represents the number of objects in the collection.

ListObjects.Item returns a single object from a collection.

ListObjects.Parent returns the parent object for the specified object. Read-only.