Excel VBA 单元格格式

https://www.cnblogs.com/kernel0815/p/3315893.html
1. 单元格水平 竖向居中

Sheet.Range(“A6”).HorizontalAlignment = = xlCenter ‘= 3单元格水平居中

Sheet.Range(“A6”).VerticalAlignment = xlCenter ‘=2 单元格竖向居中

此属性的值可设为以下常量之一:

xlCenter

xlDistributed

xlJustify

xlLeft

  1. 设置单元格边框

Range对象的Borders集合可快速对单元格区域的每个边框应用相同格式

Range对象的BorderAround方法添加区域一个外边框。

例:Range(“A1:C5”)Borders(index).color=vbRead

Range(“B2:C5”)BorderAround(LineStyle , Weight , ColorIndex, Color)

其中Colorlndex参数可以指定当前调色板中的颜色,Color参数以RGB值指定边框的颜色,可以是当前调色板以外的颜色,但是不能同时指定这两个参数。
Excel VBA 单元格格式
XlBorderWeight 枚举

指定某一区域周围的边框的粗细。
Excel VBA 单元格格式
XlLineStyle 枚举

指定边框的线条样式。
Excel VBA 单元格格式

Borders(index)

Excel VBA 单元格格式