Class ListColumns (Excel VBA)

A collection of all the ListColumn objects in the specified ListObject object. To use a ListColumns class variable it first needs to be instantiated, for example


Dim lcs as ListColumns
Set lcs = ActiveCell.ListObject.ListColumns

For Each

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


Dim lstcol As ListColumn
For Each lstcol In ActiveCell.ListObject.ListColumns
	
Next lstcol

Add

Adds a new column to the list object.

If Position is not specified, a new rightmost column is added. A name for the column is automatically generated. The name of the new column can be changed after the column is added.

Add (Position)

Position: Specifies the relative position of the new column that starts at 1. The previous column at this position is shifted outward.


Dim lstcol As ListColumn
Set lstcol = ActiveCell.ListObject.ListColumns.Add()

Count

Returns an Integer value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = ActiveCell.ListObject.ListColumns.Count

Item

Returns a single object from a collection.

Item (Index)

Index: The name or index number of the object.


Dim lstcolItem As ListColumn
Set lstcolItem = ActiveCell.ListObject.ListColumns(Index:=1)