对指定区域自动套用预定义的格式。
expression.AutoFormat(Format, Number, Font, Alignment, Border, Pattern, Width)
expression 必需。该表达式返回上面的对象之一。
Format XlRangeAutoFormat 类型,可选。指定的自动套用格式。
XlRangeAutoFormat 可为以下 XlRangeAutoFormat 常量之一。 |
xlRangeAutoFormat3DEffects1 |
xlRangeAutoFormat3DEffects2 |
xlRangeAutoFormatAccounting1 |
xlRangeAutoFormatAccounting2 |
xlRangeAutoFormatAccounting3 |
xlRangeAutoFormatAccounting4 |
xlRangeAutoFormatClassic1 默认值 |
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
默认常量为 xlRangeAutoFormatClassic1。对于所选择或安装的不同语言支持(例如:美国英语),以上某些常量可能不可用。 |
Number Variant 类型,可选。如果该值为 True,则在自动套用格式中包括数字格式。默认值为 True。
Font Variant 类型,可选。如果该值为 True,则在自动套用格式中包括字体格式。默认值为 True。
Alignment Variant 类型,可选。如果该值为 True,则在自动套用格式中包括对齐方式。默认值为 True。
Border Variant 类型,可选。如果该值为 True,则在自动套用格式中包括边框格式。默认值为 True。
Pattern Variant 类型,可选。如果该值为 True,则在自动套用格式中包括图案格式。默认值为 True。
Width Variant 类型,可选。如果该值为 True,则在自动套用格式中包括列宽和行高。默认值为 True。
自动设置指定图表的格式。
expression.AutoFormat(Gallery, Format)
expression 必需。该表达式返回上面的对象之一。
Gallery Long 类型,必需。指定的库。
Format Variant 类型,可选。指定的自动套用格式。
如果区域为单个单元格,则本方法也将设置该单元格周围活动区域的格式,换句话说,下列两条语句是等价的:
Cells("A1").AutoFormat
Cells("A1").CurrentRegion.AutoFormat
本示例将预定义格式套用到 Sheet1 中的单元格区域 A1:D8 上。
Worksheets("Sheet1").Range("A1:D8"). _
AutoFormat Format:=xlRangeAutoFormatClassic1