I wrote code to hide sheets in a workbook using xlVeryHidden until a password is entered, when I unhide certain sheets.
Dim Ans As String
ActiveWorkbook.Unprotect ("12345")
Ans = InputBox("Please input your password")
If Ans = "12345" Then
Sheets("Title Sheet").Visible = True
Sheets("Page2").Visible = True
Sheets("Page3").Visible = True
' Sheets("Page4").Visible = True
Sheets("Page5").Visible = True
' Sheets("Page6").Visible = True
Sheets("Page7").Visible = True
Else
MsgBox "Wrong password, try again."
End If
Two of the 7 sheets cause a run-time error - exception has been thrown by the target of an invocation. The code works fine if I comment out the two lines above. I double-checked that these two pages have the same setup as the others - they're all password protected with the same password. Does anyone have any idea what this could be? I thought it might be a permission issue, which is why I confirmed the passwords.
Thanks,
Alexis
Dim Ans As String
ActiveWorkbook.Unprotect ("12345")
Ans = InputBox("Please input your password")
If Ans = "12345" Then
Sheets("Title Sheet").Visible = True
Sheets("Page2").Visible = True
Sheets("Page3").Visible = True
' Sheets("Page4").Visible = True
Sheets("Page5").Visible = True
' Sheets("Page6").Visible = True
Sheets("Page7").Visible = True
Else
MsgBox "Wrong password, try again."
End If
Two of the 7 sheets cause a run-time error - exception has been thrown by the target of an invocation. The code works fine if I comment out the two lines above. I double-checked that these two pages have the same setup as the others - they're all password protected with the same password. Does anyone have any idea what this could be? I thought it might be a permission issue, which is why I confirmed the passwords.
Thanks,
Alexis