excel - 你知道如何在 VBA 代码中标记行吗?
问题描述
我想区分我的 VBA 代码中的行,尤其是对命令。我尝试将它们级联起来,但是尽管我努力了,但有时我会迷失哪对代码属于/在哪里结束,当我在其他循环中有更多循环时。有没有办法用颜色标记线条?所以我可以通过颜色区分对命令?
谢谢你。
杰克
解决方案
不幸的是,VBA 编辑器中没有匹配if和结束endif的功能。我使用 Rubberduck,一个免费的 VBA 插件。有了它,您可以轻松缩进代码并使其更具可读性。
前:
Option Explicit
Function test(a As Integer)
Dim b As Integer
b = 1
If a > 1 Then
b = 2
If a > 21 Then
b = 3
Else
b = 4
End If
End If
test = b
End Function
经Rubberduck处理后:
Option Explicit
Function test(a As Integer)
Dim b As Integer
b = 1
If a > 1 Then
b = 2
If a > 21 Then
b = 3
Else
b = 4
End If
End If
test = b
End Function
它还可以做更多的事情。你可以在这里下载:http ://rubberduckvba.com/
推荐阅读
- android - 使用 Terraform 创建 AWS Amplify 资源
- python - 正弦函数 - Python
- webpack - eslint-webpack-plugin 输出格式错误
- java - 关于随机(x)和随机()%x的数学问题 - Java
- docker - 我可以在没有 bash 脚本的情况下使用 docker-compose 来检查容器,然后将文件从容器复制到主机吗?
- image-processing - 如何对二维码中的某些像素实施约束?
- jasperserver - Jasper 服务器“不支持融合组件”渲染 PDF
- c++ - 类型别名在类中有什么作用?
- sql - 一年无记录后的新纪录
- python - 在 Python 中从 3 元素元组创建字典 - TypeError