Remarks

Each Style object 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.

Example

Use the property to return the Styles collection. The following example creates a list of style names on worksheet one in the active workbook.

Visual Basic for Applications
For i = 1 To ActiveWorkbook.Styles.Count Worksheets(1).Cells(i, 1) = ActiveWorkbook.Styles(i).Name Next

Use the method to create a new style and add it to the collection. The following example creates a new style based on the Normal style, modifies the border and font, and then applies the new style to cells A25:A30.

Visual Basic for Applications
With ActiveWorkbook.Styles.Add(Name:="Bookman Top Border") .Borders(xlTop).LineStyle = xlDouble .Font.Bold = True .Font.Name = "Bookman" End With Worksheets(1).Range("A25:A30").Style = "Bookman Top Border"

Use Styles(), where is the style index number or name, to return a single Styleobject from the workbook Stylescollection. The following example changes the Normal style for the active workbook by setting its Boldproperty.

Visual Basic for Applications
ActiveWorkbook.Styles("Normal").Font.Bold = True
Styles Collection Styles Collection Object

See also:

index index