Excel 通过宏使用多张工作表保护整个工作簿
我想保护包含多张工作表的整个工作簿。还需要对所有板材进行保护。有什么方法可以做到这一点吗?您可以从这里开始:Excel 通过宏使用多张工作表保护整个工作簿,excel,vba,password-protection,Excel,Vba,Password Protection,我想保护包含多张工作表的整个工作簿。还需要对所有板材进行保护。有什么方法可以做到这一点吗?您可以从这里开始: Sub protect() Dim s As String Dim ws As Worksheet s = InputBox("Enter Password", "Protection", "") For Each ws In ThisWorkbook.Worksheets ws.protect s Next ws ThisWorkbook.protect s End Sub
Sub protect()
Dim s As String
Dim ws As Worksheet
s = InputBox("Enter Password", "Protection", "")
For Each ws In ThisWorkbook.Worksheets
ws.protect s
Next ws
ThisWorkbook.protect s
End Sub
Sub unprotect()
Dim s As String
Dim ws As Worksheet
s = InputBox("Enter Password", "Protection", "")
For Each ws In ThisWorkbook.Worksheets
ws.unprotect s
Next ws
ThisWorkbook.unprotect s
End Sub
更改为与其他工作簿和/或密码一起使用。在什么意义上更快?我们可以直接使用某些功能,而不是申请循环并逐个处理每张工作表吗?我有一个非常大的excel文件,有63个选项卡,应用这个循环需要时间来运行宏。你试过了吗?您只需输入一次密码。所以for循环应该运行得相当快。