Class TableStyle (Excel VBA)

The class TableStyle represents a single style that can be applied to a table or slicer.

The main procedures of class TableStyle are Delete and TableStyles.Add

Set

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

Dim strTableStyleName As String: strTableStyleName = 
Dim wb As Workbook: Set wb = 
Dim tblsty As TableStyle
Set tblsty = wb.TableStyles.Add(TableStyleName:=strTableStyleName)

The following procedures can be used to set variables of type TableStyle: ListObject.TableStyle, Duplicate, TableStyles.Item, TableStyles.Add, Workbook.DefaultPivotTableStyle, Workbook.DefaultTableStyle, Workbook.DefaultSlicerStyle and Workbook.TableStyles

For Each

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

Dim wb As Workbook: Set wb = 
Dim tblstyDefaultSlicerStyle As TableStyle
For Each tblstyDefaultSlicerStyle In wb.DefaultSlicerStyle
	
Next tblstyDefaultSlicerStyle

Methods

These are the main methods of the TableStyle class

Delete - Deletes the TableStyle object.

TableStyles.Add - Creates a new TableStyle object and adds it to the collection.

Properties

BuiltIn true if the style is a built-in style.

Name returns the name of the object.

NameLocal returns or sets the name of the object in the language of the user.

Parent returns the parent object for the specified object. Read-only.

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

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

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

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

TableStyleElements returns the TableStyleElements object.

TableStyles.Count returns the number of objects in the collection.

TableStyles.Parent returns the parent object for the specified object. Read-only.