'单元格选择方法
Range("A1").Select                                      '选择A1单元格
Range("A1,C1").Select                                  '选择A1、C1单元格
Range("A1:C2").Select                                  '选择A1至C2单元格区域          Rows("1:1").Select                                      '选择第1行
Range("1:1,3:3").Select                                '选择第1、3行
Rows("1:3").Select                                      '选择第1至3行
Columns("A:A").Select                                  '选择A列
Columns("A:C").Select                                  '选择A至C列
Cells.Select                                            '选择全部单元格
'单元格格式设置-数字
Selection.NumberFormatLocal = "G/通用格式"              '分类(C)_常规
Selection.NumberFormatLocal = "0.00_ "                  '分类(C)_数值
Selection.NumberFormatLocal = "¥#,##0.00;¥-#,##0.00"  '分类(C)_货币
Selection.NumberFormatLocal = "_ ¥* #,##0.00_ ;_ ¥* -#,##0.00_ ;_ ¥* ""-""??_          Selection.NumberFormatLocal = "yyyy-m-d"                '分类(C)_日期
Selection.NumberFormatLocal = "[$-F400]h:mm:ss AM/PM"  '分类(C)_时间
Selection.NumberFormatLocal = "0.00%"                  '分类(C)_百分比
Selection.NumberFormatLocal = "# ?/?"                  '分类(C)_分数
Selection.NumberFormatLocal = "0.00E+00"                '分类(C)_科学记数
Selection.NumberFormatLocal = "@"                      '分类(C)_文本
Selection.NumberFormatLocal = "000000"                  '分类(C)_特殊
Selection.NumberFormatLocal = "G/通用格式"              '分类(C)_自定义
注:以上红00为小数位数。
'单元格格式设置-对齐
With Selection
.HorizontalAlignment = xlGeneral                    '水平对齐(H)_常规
xlLeft                      '水平对齐(H)_靠左(缩进)                                      xlCenter                    '水平对齐(H)_居中
xlRight                      '水平对齐(H)_靠右(缩进)                                      xlFill                      '水平对齐(H)_填充
xlJustify                    '水平对齐(H)_两端对齐(缩                                    xlCenterAcrossSelection      '水平对齐(H)_跨列居中                                      xlDistributed                '水平对齐(H)_分散对齐(缩              .VerticalAlignment = xlTop                          '垂直对齐(V)_靠上
xlCenter                      '垂直对齐(V)_居中
xlBottom                      '垂直对齐(V)_靠下
xlJustify                      '垂直对齐(V)_两端对齐                                    xlDistributed                  '垂直对齐(V)_分散对齐              .WrapText = False                                  '文本控制_自动换行(W)              .Orientation = 0                                    '方向_横向0度(D)
xlVertical                          '方向_竖向
html设置字体颜属性.AddIndent = False
.IndentLevel = 0                                    '缩进_0(I)
.ShrinkToFit = False                                '文本控制_缩小字体填充(K
.ReadingOrder = xlContext                          '文字方向(T)_根据内容
xlLTR                              '文字方向(T)_总是从左到右                              xlRTL                              '文字方向(T)_总是从右到左              .MergeCells = False                                '文本控制_合并单元格(M)          End With
'单元格格式设置-字体
With Selection.Font
.Name = "宋体"                                      '字体(F)_“宋体”
.FontStyle = "常规"                                '字形(O)_“常规”
.Size = 12                                          '字号(S)_12
.Strikethrough = False                              '特殊效果_删除线
.Superscript = False                                '特殊效果_上标
.Subscript = False                                  '特殊效果_下标
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone                  '下划线(U)
xlUnderlineStyleSingle                '单下划线
xlUnderlineStyleDouble                '双下划线
xlUnderlineStyleSingleAccounting      '会计用单下划线
xlUnderlineStyleDoubleAccounting      '会计用双下划线
.ColorIndex = xlAutomatic                          '颜(C)_自动
End With
'单元格格式设置-边框
Selection.Borders(xlDiagonalDown).LineStyle = xlNone    '右下斜线
Selection.Borders(xlDiagonalUp).LineStyle = xlNone      '左下斜线
Selection.Borders(xlEdgeLeft).LineStyle = xlNone        '左框线
Selection.Borders(xlEdgeTop).LineStyle = xlNone        '上框线
Selection.Borders(xlEdgeBottom).LineStyle = xlNone      '下框线
Selection.Borders(xlEdgeRight).LineStyle = xlNone      '右框线
Selection.Borders(xlInsideVertical).LineStyle = xlNone  '内竖线
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone '内横线
Selection.Interior.ColorIndex = xlNone                  '线条颜(C)_自动
'-----------------------------------------
With Selection.Borders(xlDiagonalDown)                  '右下斜线
.LineStyle = xlContinuous                          '线条样式_虚线线型___实线              .Weight = xlThin                                    '线条样式_线型(线宽)_细              .ColorIndex = xlAutomatic                          '线条颜(C)_自动
End With
With Selection.Borders(xlDiagonalUp)                    '左下斜线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeLeft)                      '左框线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)                      '上框线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)                    '下框线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)                    '右框线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)                '内竖线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With  Selection.Borders(xlInsideHorizontal)            '内横线
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'单元格格式设置-图案
Selection.Interior.ColorIndex = xlNone                  '单元格底纹  (无设置 )          '-----------------------------------------
With  Selection.Interior
.ColorIndex = 0                                    '单元格底纹_颜(C)_无颜              .Pattern = xlSolid                                '单元格底纹_图案(P)
.PatternColorIndex = xlAutomatic                  '单元格底纹_图案(P)颜          End With
'单元格格式设置-保护
Selection.Locked = True                                '锁定 (L)
Selection.FormulaHidden = False                        '隐藏 (I)
颜9与颜30相同,表中未列出。
单元格填充图案颜的代码与单元格填充颜的代码相同
'单元格边框设置
With Selection.Borders(xl******)
.LineStyle =
.Weight =
.ColorIndex =
End With
选择A1单元格
选择A1、C1单元格
选择A1至C2单元格区域
选择第1行
选择第1、3行
选择第1至3行
选择A至C列
选择全部单元格
分类(C)_常规
分类(C)_数值
_货币
##0.00_ ;_ ¥* ""-""??_ ;_ @_ "分类(C)_日期
分类(C)_时间
分类(C)_百分比
_分数
分类(C)_科学记数
_文本
分类(C)_特殊
分类(C)_自定义
水平对齐(H)_常规
水平对齐(H)_靠左(缩进)
水平对齐(H)_居中
水平对齐(H)_靠右(缩进)
水平对齐(H)_填充
水平对齐(H)_两端对齐(缩进)
水平对齐(H)_跨列居中
水平对齐(H)_分散对齐(缩进)
垂直对齐(V)_靠上
垂直对齐(V)_居中
垂直对齐(V)_靠下
垂直对齐(V)_两端对齐
垂直对齐(V)_分散对齐
文本控制_自动换行(W)
方向_横向0度(D)
方向_竖向
缩进_0(I)
文本控制_缩小字体填充(K)