We help IT Professionals succeed at work.

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.
Watch Question

You can try the
property. For more discussions on this you can see



Roy CoxGroup Finance Manager

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