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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saqib Husain, SyedEngineerCommented:
You can try the
property. For more discussions on this you can see


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.