ExcelVBA设置表格颜色

标签:
excelvbaoffice表格宏 |
色值方式:
Cells(1,2).Font.ColorIndex = 3 '字的颜色号为3 红色
Cells(1, 2).Interior.ColorIndex = 3 ' 背景的颜色为3 红色
RGB方式:
Cells(2, 3).Font.Color = RGB(0, 255, 0) '字的颜色绿色
Cells(2, 3).Interior.Color = RGB(0, 0, 255) '背景的颜色蓝色
或者比如底色填充范围(Interior):
Range("A3:B4").Interior.ColorIndex = 3
网格线条颜色(Borders):
ActiveWindow.GridlineColorIndex=5'全部
Range("A3").Borders.ColorIndex = 3
边框样式:
Range("A3:B4").Borders.LineStyle = xlContinuous'边线风格
Range("A3:B4").Borders.Weight = xlThick'边线宽度
清除:
Range("A1").Interior.Pattern = xlNone'底色
Cells(1,1).Interior.ColorIndex = xlNone
Cells.Interior.ColorIndex = xlNone'全部底色恢复默认
Cells.Borders.ColorIndex = xlNone'全部边线恢复默认
颜色值:

边线风格: