ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   unprotect sheet in code and make sheet visible (https://www.excelbanter.com/excel-programming/273206-unprotect-sheet-code-make-sheet-visible.html)

peach255

unprotect sheet in code and make sheet visible
 
I have a worksheet that is hidden. Whenever the checkmark
is clicked, which would result in F12="TRUE", then I want
it to open this other sheet called "Polymerase". However,
the sheet is protected w/ a password, and I do not want it
to prompt the user w/ the password.
I have the following code so far:

If Worksheets("Instructions").Range("F12") = True Then
Sheets("Polymerase").unprotect password:="INGRAM"
Sheets("Polymerase").Visible = True
Sheets("Polymerase").Select
Else
Sheets("Polymerase").Visible = False
End If

And I get a " Run-time error '1004' Unable to set the
Visible property of the Worksheet class. "

Thank you!

Dave Peterson[_3_]

unprotect sheet in code and make sheet visible
 
Are you running xl97?

Is your code associated with a checkbox from the controltoolbox toolbar?
If yes, then try adding:
activecell.activate
to the top of your code.

If it's run from a control from the control toolbox toolbar that has a
takefocusonclick property, you can change that to False.

(It's a bug that was fixed in xl2k.)

If none of this was true, then post back with your version of excel, where the
code is located, and how it's called.





peach255 wrote:

I have a worksheet that is hidden. Whenever the checkmark
is clicked, which would result in F12="TRUE", then I want
it to open this other sheet called "Polymerase". However,
the sheet is protected w/ a password, and I do not want it
to prompt the user w/ the password.
I have the following code so far:

If Worksheets("Instructions").Range("F12") = True Then
Sheets("Polymerase").unprotect password:="INGRAM"
Sheets("Polymerase").Visible = True
Sheets("Polymerase").Select
Else
Sheets("Polymerase").Visible = False
End If

And I get a " Run-time error '1004' Unable to set the
Visible property of the Worksheet class. "

Thank you!


--

Dave Peterson



All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com