我有5个工作表在我的Excel工作簿,但我想特别保护第三和第五个工作表的密码

我在我的Excel工作簿中有5个工作表,但是我想用密码特别保护第三和第五个工作表。 有下面只保护一张纸的macros。 需要添加什么来保护多张表单而不是所有表单。 请引导我。

提前致谢!!

Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim MySheets As String, Response As String MySheet = "Sheet1" If ActiveSheet.Name = MySheet Then ActiveSheet.Visible = False Response = InputBox("Enter password to view sheet") If Response = "pass" Then Sheets(MySheet).Visible = True Application.EnableEvents = False Sheets(MySheet).Select Application.EnableEvents = True End If End If Sheets(MySheet).Visible = True End Sub 

尝试这个:

 Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim MySheets As String, Response As String MySheet = ActiveSheet.Name Select Case MySheet Case "Sheet1", "Sheet3", "Sheet5" ActiveSheet.Visible = False Response = InputBox("Enter password to view sheet") If Response = "pass" Then Sheets(MySheet).Visible = True Application.EnableEvents = False Sheets(MySheet).Select Application.EnableEvents = True End If End Select Sheets(MySheet).Visible = True End Sub 

但是对密码进行硬编码并不能保证安全。