Using "protection" as a macro condition

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to refer to "protection" (its on/off condition), in a Macro
line?
A simple example would be -

If "protection is off" Then Worksheets("abc").Range("a5").Value = 0

I need to know the coding to use that would replace "protection is off" in
the above line. It could also be connected to whether or not there is a
password present.
I hope this can be done.
Ed
 
Look at help on

Protectcontents
ProtectDrawingObject
ProtectScenarios

If Worksheets("Sheet1").ProtectContents = True Then
MsgBox "The contents of Sheet1 are protected."
End If


In excel 2002 and later, also look at the protection object.

I am not away of any property that will tell you if a password is required.
No sure how useful it would be as you can try to unprotect the sheet without
one, then see if you were successful or check the error (using On Error
Resume Next to ignore an error response).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top