提供一种思路,可以通过修改以下部分的代码。或者给这些代码设定执行条件,把你要设置的单个工作表分离出来设定单独条件,当条件满足时按你设定的保护方法保护,否则执行通用保护。记得同时要设有解保护的代码。 Sub SheetP()
For i = 1 To Sheets.Count
If Sheets(i).Name <> "注册表" Then Sheets(i).Protect ("ABCacb333")
Next
End Sub
Sub unSheetP()
For i = 1 To Sheets.Count
If Sheets(i).Name <> "注册表" Then Sheets(i).Unprotect ("ABCacb333")
Next
End Sub
注册表WorkSheet代码为: Private Sub Worksheet_Activate()
ThisWorkbook.Unprotect ("ABCacb333")
For i = 1 To Sheets.Count
If Sheets(i).Name <> "注册表" Then Sheets(i).Visible = 2
Next
ThisWorkbook.Protect ("ABCacb333")
End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range)
UserForm1.Show 0
End Sub ThisWorkbook代码为: Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Unprotect ("ABCacb333")
For i = 1 To Sheets.Count
If Sheets(i).Name <> "注册表" Then Sheets(i).Visible = xlSheetVeryHidden
Next
ThisWorkbook.Protect ("ABCacb333")
End Sub |