Applies To
Range Object.
Description
Automatically formats a range of cells using a predefined format.
Syntax
object.AutoFormat(format, number, font, alignment, border, pattern, width)
object
Required. The range to format.
format
Optional. The name or number of the format to apply (one of xlClassic1, xlClassic2, xlClassic3, xlAccounting1, xlAccounting2, xlAccounting3, xlAccounting4, xlColor1, xlColor2, xlColor3, xlList1, xlList2, xlList3, xl3DEffects1, xl3DEffects2, xlSimple, or xlNone). If this argument is omitted, the default value is xlClassic1.
number
Optional. Corresponds to the Number check box in the AutoFormat dialog box. Can be True or False (True if omitted).
font
Optional. Corresponds to the Font check box in the AutoFormat dialog box. Can be True or False (True if omitted).
alignment
Optional. Corresponds to the Alignment check box in the AutoFormat dialog box. Can be True or False (True if omitted).
border
Optional. Corresponds to the Border check box in the AutoFormat dialog box. Can be True or False (True if omitted).
pattern
Optional. Corresponds to the Pattern check box in the AutoFormat dialog box. Can be True or False (True if omitted).
width
Optional. Corresponds to the Column Width/Row Height check box in the AutoFormat dialog box. Can be True or False (True if omitted).
Remarks
If the range is a single cell, this method also formats the current region around the cell. In other words, the AutoFormat method performs CurrentRegion.AutoFormat on the single cell.
In Japanese Microsoft Excel, the following additional formats are available: xlLocalFormat1 and xlLocalFormat2.
See Also
AutoFormat Method (Chart object), CurrentRegion Property, Style Property.
Example
This example formats cells A1:D8 on Sheet1, using a predefined format.
Worksheets("Sheet1").Range("A1:D8").AutoFormat format:=xlClassic1