Class TableStyleElement (Excel VBA)

The class TableStyleElement represents a single table style element.


To use a TableStyleElement class variable it first needs to be instantiated, for example

Dim tblele as TableStyleElement
Set tblele = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(Index:=1)

TableStyleElement class variables can be set using the TableStyleElements.Item procedure.

For Each

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

Dim tblele As TableStyleElement
For Each tblele In ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements
Next tblele


Returns a Borders collection that represents the borders of a TableStyleElement object.

Dim brdsBorders As Borders
Set brdsBorders = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(1).Borders


Clears the formatting for this element.



Returns a Font object that represents the font of the specified object.

Dim fntFont As Font
Set fntFont = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(1).Font


Returns whether a table style element has formatting applied to the specified element.

Dim booHasFormat As Boolean
booHasFormat = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(1).HasFormat


Returns an Interior object that represents the interior of the specified object.

Dim intInterior As Interior
Set intInterior = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(1).Interior


Returns or sets the size of banding.

This property does not apply to all TableStyleElement objects. It applies only to xlColumnStripe1, xlColumnStripe2, xlRowStripe1, and xlRowStripe2 types (for more information, see XlTableStyleElementType).

ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(1).StripeSize =


Returns the number of objects in the collection.

Dim lngCount As Long
lngCount = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements.Count


Returns a single TableStyleElement object from the collection.

Item (Index)

Index: A table style element.

Dim tblele As TableStyleElement
Set tblele = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements(Index:=1)