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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with error handling syntax

Status
Not open for further replies.

GrahamUNC

Programmer
Mar 30, 2001
14
0
0
US
I know what I want to say in English but can't come up with the right code that will do what I want. Here's kind of what I want the code to do using my English/VBA sub-dialect. Sorry for the non-technicalness of the code:


On error goto handler

Handler:
if the worksheet is protected then
unprotect the worksheet
resume the sub
then protect the worksheet that was just unprotected

I apologize if this makes little to no sense.
 


Are you looking for ActiveWorkbook.Unprotect, ActiveWorkbook.Protect?

Stew

"Even a stopped clock tells the right time twice a day."
 
Here is my solution for the worksheet protection problem:

Sub Protect()
On Error GoTo Handler
Range("A2") = 20
ActiveSheet.Protect
Exit Sub
Handler:
ActiveSheet.Unprotect
Resume
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top