Class TableStyle (Excel VBA)

The class TableStyle represents a single style that can be applied to a table or slicer. To use a TableStyle class variable it first needs to be instantiated, for example


Dim tblsty as TableStyle
Set tblsty = ActiveWorkbook.DefaultPivotTableStyle

For Each

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


Dim tblstyDefaultSlicerStyle As TableStyle
For Each tblstyDefaultSlicerStyle In Application.DefaultSlicerStyle
	
Next tblstyDefaultSlicerStyle

BuiltIn

True if the style is a built-in style.


Dim booBuiltIn As Boolean
booBuiltIn = ActiveWorkbook.DefaultPivotTableStyle.BuiltIn

Delete

Deletes the TableStyle object.


ActiveWorkbook.DefaultPivotTableStyle.Delete

Duplicate

Duplicates the TableStyle object and returns a reference to the new copy.

If no name is specified, the Duplicate method uses the same default name as the user interface.

Duplicate (NewTableStyleName)

NewTableStyleName: The name of the new table style.


Dim tblstyDuplicate As TableStyle
Set tblstyDuplicate = ActiveWorkbook.DefaultPivotTableStyle.Duplicate()

Name

Returns the name of the object.


Dim strName As String
strName = ActiveWorkbook.DefaultPivotTableStyle.Name

NameLocal

Returns or sets the name of the object in the language of the user.

If the style is a built-in style, this property returns the name of the style in the language of the current locale.


Dim strNameLocal As String
strNameLocal = ActiveWorkbook.DefaultPivotTableStyle.NameLocal

ShowAsAvailablePivotTableStyle

Sets or returns whether a style is shown in the gallery for PivotTable styles.

The property returns True if the style is shown in the gallery for PivotTable styles.


ActiveWorkbook.DefaultPivotTableStyle.ShowAsAvailablePivotTableStyle = True

ShowAsAvailableSlicerStyle

Returns or sets whether the specified table style is shown as available in the slicer styles gallery.


ActiveWorkbook.DefaultPivotTableStyle.ShowAsAvailableSlicerStyle = True

ShowAsAvailableTableStyle

Returns or sets a table style shown as available in the table styles gallery.

If True, this style is shown in the gallery for table styles. You can set this property to False even when the style is already applied to a table. In this case, the gallery will not show the style, and when the active cell is in that table, no style is shown as selected.


ActiveWorkbook.DefaultPivotTableStyle.ShowAsAvailableTableStyle = True

ShowAsAvailableTimelineStyle

Returns or sets whether the specified table style is shown as available in the timeline styles gallery.


ActiveWorkbook.DefaultPivotTableStyle.ShowAsAvailableTimelineStyle = True

TableStyleElements

Returns the TableStyleElements object.


Dim tsesTableStyleElements As TableStyleElements
Set tsesTableStyleElements = ActiveWorkbook.DefaultPivotTableStyle.TableStyleElements