我想对一定区域设置格式为文本、横居中、竖居中、宋体、常规、8号、加边框、着底色,但是选择后进行设置的,能否直接赋予格式? 我的代码如下, Sub Macro3() '表头内容、格式处理 Application.ScreenUpdating = False 表头 = Array("编号", "年度", "拨付单位", "拨付对象", "分配金额", "本级配套", "拨付金额", "拨付时间", "备注", "区划简码") Sheets(Array(1, 2, 3)).Select '"分配表", "分配明细表")).Select Rows("1:1").Select Selection.Clear Range("A1:J1").Select Selection.Value = 表头 Selection.NumberFormatLocal = "@" With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter End With With Selection.Font .Name = "宋体" .FontStyle = "常规" .Size = 9 End With Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -0.249977111117893 .PatternTintAndShade = 0 End With Sheets(4).Select With Sheets(1) .Range("e1").Insert Shift:=xlToRight .Range("e1").Value = "上年结转" End With Sheets(4).Select Application.ScreenUpdating = True End Sub |