Style Object

Description

Represents a style description for a range. The Style object contains all style attributes (font, number format, alignment, and so on) as properties. There are several built-in styles, including Normal, Currency, and Percent. Using the Style object is a fast and efficient way to change several cell-formatting properties on multiple cells at the same time.

For the Workbook object, the Style object is a member of the Styles collection. The Styles collection contains all the defined styles for the workbook.

Using the Style Object

Use the Style property to return the Style object used with a Range object. The following example applies the Percent style to cells A1:A10 on Sheet1.

Worksheets("sheet1").Range("a1:a10").Style.Name = "percent"
You can change the appearance of a cell by changing properties of the style applied to that cell. Keep in mind, however, that changing a style property will affect all cells already formatted with that style.

Use Styles(index), where index is the style index number or name, to return a single Style object from the workbook Styles collection. The following example changes the Normal style for the active workbook by setting the style's Bold property.

ActiveWorkbook.Styles("Normal").Font.Bold = True
Styles are sorted alphabetically by style name. The style index number denotes the position of the specified style in the sorted list of style names. Styles(1) is the first style in the alphabetic list, and Styles(Styles.Count) is the last one in the list.

For more information about creating and modifying a style, see the Styles object.

Properties

AddIndent property, Application property, Borders property, BuiltIn property, Creator property, Font property, FormulaHidden property, HorizontalAlignment property, IncludeAlignment property, IncludeBorder property, IncludeFont property, IncludeNumber property, IncludePatterns property, IncludeProtection property, IndentLevel property, Interior property, Locked property, MergeCells property, Name property, NameLocal property, NumberFormat property, NumberFormatLocal property, Orientation property, Parent property, ReadingOrder property, ShrinkToFit property, Value property, VerticalAlignment property, WrapText property.

Methods

Delete method.