Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error message making sheets visible after using xlVeryHidden

Status
Not open for further replies.

alexisb

Programmer
Apr 5, 2001
100
US
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
 



Please post this CODE question in VBA Visual Basic for Applications (Microsoft) Forum707.

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top