office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

VBA设置单元格颜色字体

2020-05-28 08:00:00
zstmtony
原创
8293

SUB 设置单元格颜色字体等()


ActiveSheet.Range("A1:B5").Interior.ColorIndex = 2
ActiveSheet.Range("A1:B5").Borders.LineStyle = xlContinuous
ActiveSheet.Range("A1:B5").HorizontalAlignment = Excel.xlCenter
ActiveSheet.Range("A1:B5").Font.Name = "宋体"

ActiveSheet.Range("A1:B5").Font.Size = "12"


END SUB


相关参考

Sub 设置字体属性() '利用with

    With ActiveWorkbook.Sheets(1).Range([a2], [a2].End(xlDown)).Font

        .Bold = True '加粗

        .Italic = True '倾斜

        .ColorIndex = 3 '红色

        .Name = '微软雅黑' '设定字体

        .Size = 21 '字体大小

        .Strikethrough = False '不要下划线

        .Superscript = fasle '不要上标

        .Subscript = fasle '不要下标

        .Underline = xlUnderlineStyleDouble '指定双下画线

    End With

End Sub


分享