Class PivotLines (Excel VBA)

The PivotLines object is a collection of lines in a PivotTable, containing all lines on rows or columns of the pivot. Each line is a set of PivotCell objects. To use a PivotLines class variable it first needs to be instantiated, for example


Dim pls as PivotLines
Set pls = ActiveCell.PivotTable.PivotColumnAxis.PivotLines

For Each

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


Dim pvtln As PivotLine
For Each pvtln In ActiveCell.PivotLines
	
Next pvtln

Count

Returns the number of items in the PivotLines collection.


Dim lngCount As Long
lngCount = ActiveCell.PivotTable.PivotColumnAxis.PivotLines.Count

Item

Returns a specific element of the PivotLines collection object by its position in the collection.

Item (Index)

Index: Specifies the position of an element of the collection.


Dim pvtlnItem As PivotLine
Set pvtlnItem = ActiveCell.PivotTable.PivotColumnAxis.PivotLines(Index:=1)