Excel VBA - Detect Sheet Protection Status

Is there code I can use (maybe in an if statement) that checks the current protection status of a sheet?

For example, if I use 2 toggle buttons to protect or unprotect a sheet BUT there are other piece of code in other modules that also protect and unprotect the sheet then I need those toggle buttons to react to the current status versus only when the user presses those.  The problem now is the toggle buttons may look like the sheet is protected when it really isn't.
Who is Participating?
Saqib Husain, SyedEngineerCommented:
You can try the
property. For more discussions on this you can see

rmc71291Author Commented:
Roy CoxGroup Finance ManagerCommented:
If you don't want the bother of checking then you can use ProtectWithUserInterFaceOnly to allow macros to make changes on protected sheets. See


What you asked for could be

If ActiveSheet.ProtectContents Then
            msgbox ActiveSheet.Name & " is protected"
             msgbox ActiveSheet.Name & " is not protected"
        End If

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.