写一段excel vba脚本,美化下页面
时间: 2023-06-01 20:03:49 浏览: 185
Sub BeautifyPage()
'隐藏网格线
ActiveWindow.DisplayGridlines = False
'设置字体大小和颜色
Range("A1:Z100").Font.Size = 12
Range("A1:Z100").Font.Color = RGB(0, 0, 0)
'设置单元格背景色
Range("A1:Z1").Interior.Color = RGB(255, 192, 0)
Range("A2:A100").Interior.Color = RGB(217, 217, 217)
Range("B2:B100").Interior.Color = RGB(255, 255, 255)
'设置单元格边框
With Range("A1:Z100").Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Range("A1:Z100").Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Range("A1:Z100").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Range("A1:Z100").Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'设置表格自适应列宽
Columns("A:Z").AutoFit
'设置标题居中
Range("A1:Z1").HorizontalAlignment = xlCenter
End Sub
阅读全文