Name

Application.AddCustomList(ListArray, [ByRow])

Synopsis

Creates a new automatic list based on an array or a range of cells.

Argument

Setting

ListArray

The array or range of cells containing the items for the list.

ByRow

True creates the list from rows in a range; False creates the list from columns in the range. Ignored if ListArray is a single row or column. Causes an error if ListArray is not a range.

The first item in each list must be unique. An error occurs if a list with an identical first item already exists. The following code creates a new custom list from a range on the active worksheet:

Sub TestCustomList(  )
    Application.AddCustomList [a1:a10]
End Sub

To see the new list, choose Tools → Options → Custom Lists.

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.