网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 生活知识 知识问答

怎样使用VBA选择粗线边框之单元格?

时间:2026-02-15 19:34:33

1、首先在开发工具中打开VBA编辑器

怎样使用VBA选择粗线边框之单元格?

2、在单元格区域当中输入一些内容作为例子

怎样使用VBA选择粗线边框之单元格?

3、在VBA编辑器中插入模块

怎样使用VBA选择粗线边框之单元格?

4、在模块当中输入如下代码,然后运行

Sub 选择粗线边框之单元格()


    On Error Resume Next
    Dim rng As Range, rg As Range
    For Each rng In ActiveSheet.UsedRange
        If rng.Borders(xlEdgeRight).Weight = xlMedium And rng.Borders(xlEdgeTop).Weight = xlMedium _
        And rng.Borders(xlEdgeBottom).Weight = xlMedium And rng.Borders(xlEdgeLeft).Weight = xlMedium Then
        If rg Is Nothing Then
          Set rg = rng
        Else
          Set rg = Application.Union(rg, rng)
        End If
    End If
Next
rg.Select
End Sub

怎样使用VBA选择粗线边框之单元格?

5、使用快捷键Alt+F8调出运行宏窗口,然后单击“执行”按钮,可以看到所有加粗实线边框之单元格已被选中

怎样使用VBA选择粗线边框之单元格?

© 2026 阿力知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com