Excel VBA表格边框“Borders集合”解读

==标题==

|----------------------------|
| Excel VBA表格边框"Borders集合"解读 |

==正文==

|----------------------------|
| 解决问题 |
| Excel VBA表格边框"Borders集合"解读 |

一、录制宏

你打开Excel,录制宏,选择一个区域,填充所有边框,

按F11,在模板中,有宏代码,系统自己生成的

二、解读宏代码:代码注释中

sql 复制代码
Sub 宏2()' 宏2 宏'    Range("A1:C4").Select    'xlDiagonalDown\从区域中每个单元格的左上角到右下角的边框=xlNone    Selection.Borders(xlDiagonalDown).LineStyle = xlNone    'xlDiagonalUp从区域中每个单元格的左下角到右上角的边框=xlNone    Selection.Borders(xlDiagonalUp).LineStyle = xlNone    '区域左边缘的边框设置    With Selection.Borders(xlEdgeLeft)'        线条实线        .LineStyle = xlContinuous'        边框颜色自动自动配色        .ColorIndex = xlAutomatic'边框线条的透明度,从-1到1        .TintAndShade = 0'设置一个 XlBorderWeight 值,该值代表边框的权重        .Weight = xlThin    End With    With Selection.Borders(xlEdgeTop)        .LineStyle = xlContinuous        .ColorIndex = xlAutomatic        .TintAndShade = 0        .Weight = xlThin    End With    With Selection.Borders(xlEdgeBottom)        .LineStyle = xlContinuous        .ColorIndex = xlAutomatic        .TintAndShade = 0        .Weight = xlThin    End With    With Selection.Borders(xlEdgeRight)        .LineStyle = xlContinuous        .ColorIndex = xlAutomatic        .TintAndShade = 0        .Weight = xlThin    End With    With Selection.Borders(xlInsideVertical)        .LineStyle = xlContinuous        .ColorIndex = xlAutomatic        .TintAndShade = 0        .Weight = xlThin    End With    With Selection.Borders(xlInsideHorizontal)        .LineStyle = xlContinuous        .ColorIndex = xlAutomatic        .TintAndShade = 0        .Weight = xlThin    End WithEnd Sub

三、属性解读

1.Borders(XlBordersIndex 枚举)

2.Borders属性

3.其他相关属性设置

所有学习资料在官网

https://learn.microsoft.com/zh-cn/office/vba/api/overview/excel

==正文结束==

==更多合集==

|---|
| |

===***===

|----|----------------------------------------------------------------------------------|----|
| 关注 | | 转发 |
| 点赞 | | 在看 |