Name

listobjects.Add([SourceType], [Source], [LinkSource], [XlListObjectHasHeaders], [Destination])

Synopsis

Creates a new list and adds it to a worksheet. The Add method returns a reference to the LinkObject that was created.

Argument

Settings

SourceType

xlSrcRange creates the list from a range of cells. xlSrcExternal inserts a list from a SharePoint server. xlSrcXml is an invalid setting and causes an error when used with the Add method.

Source

If SourceType is xlSrcRange, this argument is a range of cells to convert to a list. If SourceType is xlSrcExternal, this argument is an array identifying the source of the list.

LinkSource

True links the list to the SharePoint list if Source is xlSrcExternal; False omits the link. Must be omitted if Source is xlSrcRange.

XlListObjectHasHeaders

xlYes converts the first row of the list to text headers. xlNo Adds a new row for headers and shifts the range of cells in the list down one row. xlYesNoGuess causes Excel to evaluate whether the first row contains text headers and adds a header row if it does not seem to exist.

Destination

If Source is xlSrcExternal, Destination must be a single cell that indicates the upper-left corner of the list to create.

The data you include in the Source array argument depends on whether you are creating a list from a range of cells or inserting a list from a SharePoint server.

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.