Class Style (Excel VBA)

The class Style represents a style description for a range.

The classes DisplayFormat, Range and Slicer. give access to class Style

Member in collection

Item

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

Dim sty as Style
Set sty = ActiveCell.Style

The following procedures can be used to set variables of type Style: DisplayFormat.Style, Range.Style, Slicer.Style, Styles.Add and Styles.Item.

For Each

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

Dim sty As Style
For Each sty In Application.Styles
	
Next sty

Methods

Delete - Deletes the object.

Styles.Add - Creates a new style and adds it to the list of styles that are available for the current workbook.

Styles.Merge - Merges the styles from another workbook into the Styles collection.

Properties

Value (Default member) - Returns a String value that represents the name of the specified style. Styles.Item (Default member) - Returns a single Style object from the collection.

AddIndent returns or sets a Boolean value that indicates if text is automatically indented when the text alignment in a cell is set to equal distribution (either horizontally or vertically).

Borders returns a Borders collection that represents the borders of a style or a range of cells (including a range defined as part of a conditional format).

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

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

FormulaHidden returns or sets a Boolean value that indicates if the formula will be hidden when the worksheet is protected.

HorizontalAlignment returns or sets an XlHAlign value that represents the horizontal alignment for the specified object.

IncludeAlignment true if the style includes the AddIndent, HorizontalAlignment, VerticalAlignment, WrapText, IndentLevel, and Orientation properties of the Style object.

IncludeBorder true if the style includes the Color, ColorIndex, LineStyle, and Weight properties of the Border object.

IncludeFont true if the style includes the Background, Bold, Color, ColorIndex, FontStyle, Italic, Name, Size, Strikethrough, Subscript, Superscript, and Underline font properties.

IncludeNumber true if the style includes the NumberFormat property.

IncludePatterns true if the style includes the Color, ColorIndex, InvertIfNegative, Pattern, PatternColor, and PatternColorIndex properties of the Interior object.

IncludeProtection true if the style includes the FormulaHidden and Locked protection properties.

IndentLevel returns or sets a Long value that represents the indent level for the style.

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

Locked returns or sets a Boolean value that indicates if the object is locked.

MergeCells true if the style contains merged cells.

Name returns a String value that represents the name of the object.

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

NumberFormat returns or sets a String value that represents the format code for the object.

NumberFormatLocal returns or sets a String value that represents the format code for the object as a string in the language of the user.

Orientation returns or sets an XlOrientation value that represents the text orientation.

ReadingOrder returns or sets the reading order for the specified object. Can be one of the following XlReadingOrder constants: xlRTL (right-to-left), xlLTR (left-to-right), or xlContext.

ShrinkToFit returns or sets a Boolean value that indicates if text automatically shrinks to fit in the available column width.

VerticalAlignment returns or sets an XlVAlign value that represents the vertical alignment of the specified object.

WrapText returns or sets a Boolean value that indicates if Microsoft Excel wraps the text in the object.

Styles.Count returns a Long value that represents the number of objects in the collection.

Borders - A collection of four Border objects that represent the four borders of a Range object or Style object.

Font - Contains the font attributes (font name, font size, color, and so on) for an object.

Interior - Represents the interior of an object.