vba - Excel - VBA 检查工作表是否不 protected

标签 vba excel

if Worksheets("test").ProtectContents我可以识别工作表是否受到保护。它只返回一个真实的,对吧?

如何检查它是否不 protected ?

If Worksheets("test").ProtectContents = True Then: Exit Sub:

For Each cell In Range("B6:B112")
...
Next cell

Else:

If Not Worksheets("test").ProtectContents Then
Dim rng As Range
...

当工作表受到保护时,必须执行 foreach 循环。如果不是工作表.. 中的部分是用于工作表未 protected 部分。
谢谢。

最佳答案

我想这就是你要找的,

If ActiveSheet.ProtectContents = True Then
MsgBox "Protected"
Else
MsgBox "Not protected"
End If

如果没有,请发表评论。希望我们能够解决您的问题。

关于vba - Excel - VBA 检查工作表是否不 protected ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45545776/

相关文章:

vba - 使用 VBA 在 Excel 中建立索引

vba - 根据当前记录的值与前一个相比更改标签的颜色

excel - 如何使用 "WorksheetFunction.Match"作为具有可变范围的数组

excel - 如何为工作簿声明灵活变量?

java - 如何格式化动态生成的单元格

excel - 从 Windows 中删除 IE 会影响 XMLHTTP60 吗?

VBA如何获取下一个单元格地址

mysql - 将 Excel 连接到 Mysql 更新问题

excel - 共享adodb模块之间的连接VBA

arrays - Excel VBA : populating cells with array values is very slow