AutoFormat Method [Excel 2003 VBA Language Reference]

Automatically formats the specified range, using a predefined format.

expression.AutoFormat(Format, Number, Font, Alignment, Border, Pattern, Width)

expression Required. An expression that returns one of the above objects.

XlRangeAutoFormat

XlRangeAutoFormat can be one of these XlRangeAutoFormat constants.
xlRangeAutoFormat3DEffects1
xlRangeAutoFormat3DEffects2
xlRangeAutoFormatAccounting1
xlRangeAutoFormatAccounting2
xlRangeAutoFormatAccounting3
xlRangeAutoFormatAccounting4
xlRangeAutoFormatClassic1default
xlRangeAutoFormatClassic2
xlRangeAutoFormatClassic3
xlRangeAutoFormatClassicPivotTable
xlRangeAutoFormatColor1
xlRangeAutoFormatColor2
xlRangeAutoFormatColor3
xlRangeAutoFormatList1
xlRangeAutoFormatList2
xlRangeAutoFormatList3
xlRangeAutoFormatLocalFormat1
xlRangeAutoFormatLocalFormat2
xlRangeAutoFormatLocalFormat3
xlRangeAutoFormatLocalFormat4
xlRangeAutoFormatNone
xlRangeAutoFormatPTNone
xlRangeAutoFormatReport1
xlRangeAutoFormatReport10
xlRangeAutoFormatReport2
xlRangeAutoFormatReport3
xlRangeAutoFormatReport4
xlRangeAutoFormatReport5
xlRangeAutoFormatReport6
xlRangeAutoFormatReport7
xlRangeAutoFormatReport8
xlRangeAutoFormatReport9
xlRangeAutoFormatSimple
xlRangeAutoFormatTable1
xlRangeAutoFormatTable10
xlRangeAutoFormatTable2
xlRangeAutoFormatTable3
xlRangeAutoFormatTable4
xlRangeAutoFormatTable5
xlRangeAutoFormatTable6
xlRangeAutoFormatTable7
xlRangeAutoFormatTable8
xlRangeAutoFormatTable9

The default constant is xlRangeAutoFormatClassic1. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

Number  Optional Variant. True to include number formats in the AutoFormat. The default value is True.

Font  Optional Variant. True to include font formats in the AutoFormat. The default value is True.

Alignment  Optional Variant. True to include alignment in the AutoFormat. The default value is True.

Border  Optional Variant. True to include border formats in the AutoFormat. The default value is True.

Pattern  Optional Variant. True to include pattern formats in the AutoFormat. The default value is True.

Width  Optional Variant. True to include column width and row height in the AutoFormat. The default value is True.

Remarks

If the range is a single cell, this method also formats the active region surrounding the cell. In other words, the following two statements are equivalent:

Cells("A1").AutoFormat
Cells("A1").CurrentRegion.AutoFormat

Example

This example formats cells A1:D8 on Sheet1, using a predefined format.

Worksheets("Sheet1").Range("A1:D8"). _
    AutoFormat Format:=xlRangeAutoFormatClassic1

Applies to | Range Collection