EXCEL VBA中非常重要的语句用法——with语句

 时间:2024-10-11 20:13:33

1、编写绘制边框的程序:'绘制置单元格边框Public Sub unitBorder() With Selection.B泠贾高框orders(xlEdgeLeft) '设置左边框 .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) '设置上边框 .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) '设置下边框 .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) '设置右边框 .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End WithEnd Sub

EXCEL VBA中非常重要的语句用法——with语句

3、运行以上程序,在A2至A4单元格绘制边框。结果如下:

EXCEL VBA中非常重要的语句用法——with语句

4、利用with语句可以简化表格绘制程序的编写,对于制表类的程序编写非常有用。

  • excel vba 实例 (可以让入门者立马提升兴趣 )
  • 在VBA中,union之应用——筛选数据!
  • word文档如何开启宏控制怎么设置宏怎么关闭宏
  • Excel表中VBA的组合框控件如何使用
  • Excel2016如何保护自己的代码不被别人查看
  • 热门搜索
    现在开什么店最赚钱 体裁是什么意思 世外桃源的意思 什么是裸官 百折不挠的意思 广州户口有什么好处 相由心生是什么意思 槐角的功效与作用 exe文件用什么打开 伤官是什么意思