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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.