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

Excel VB: Is a worksheet protected 1

Status
Not open for further replies.

jmstarbuck

Programmer
Aug 11, 2003
90
US
Hi I'm writing a macro that may or may not make changes to its worksheet. I turn protection off and disable events when it does.

Later, since I have turned protection off, I want to turn it back on, but I cannot see how to determine if the worksheet protection is currently turned on.

I want something "If activesheet.protection = True then..."

Any ideas?

J
 



Hi,

If YOU (your code) turned it off, would you not know?, Assign a boolean variable if you need a string tied around a finger.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Okay, thanks. I just thought that there had be a property to reference and didn't want to write unnecessary code.

J
 


Have you checked the Properties of the Worksheet Object?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yes, I did check the properties. I wasn't able to find exactly what I was looking for.

Do you know how to use one of the properties for what I would like to accomplish?

J
 
Once protection is turned off you cannot tell if that sheet was previously protected unless as Skip says, you set a variable or cell reference to tell you that it was

If you just want to know if the worksheet is currently protected then in 2010 you can check worksheet.protectcontents (true/false) to see if the contents of the worksheet are protected (most common form of protection as opposed to drawingobjects etc)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top