Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 1.76 KB

Excel.Application.AddCustomList.md

File metadata and controls

52 lines (32 loc) · 1.76 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Application.AddCustomList method (Excel)
vbaxl10.chm133076
vbaxl10.chm133076
Excel.Application.AddCustomList
31518c3c-78ce-f9e9-9572-a1338aa6d2e7
04/04/2019
medium

Application.AddCustomList method (Excel)

Adds a custom list for custom autofill and/or custom sort.

Syntax

expression.AddCustomList (ListArray, ByRow)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
ListArray Required Variant Specifies the source data, as either an array of strings or a Range object.
ByRow Optional Variant Only used if ListArray is a Range object. True to create a custom list from each row in the range. False to create a custom list from each column in the range.

If this argument is omitted and there are more rows than columns (or an equal number of rows and columns) in the range, Microsoft Excel creates a custom list from each column in the range.

If this argument is omitted and there are more columns than rows in the range, Excel creates a custom list from each row in the range.

Remarks

If the list that you are trying to add already exists, this method throws a run-time error 1004. Catch the error with an On Error statement.

Example

This example adds an array of strings as a custom list.

On Error Resume Next  ' if the list already exists, don'thing
Application.AddCustomList Array("cogs", "sprockets", _ 
 "widgets", "gizmos")
On Error Goto 0       ' resume regular error handling

[!includeSupport and feedback]