PDA

View Full Version : Sheet Protection - Which has precedence?



Aussiebear
04-16-2007, 02:45 AM
If you have a workbook which is manually protected by going to Tools/Protection in 2003 or Format/Protect Sheet in 2007 and you have some VBA code which requires you to use ActiveSheet.uprotect/Activesheet.Protect which has precedence when used in the same workbook and why?

Bob Phillips
04-16-2007, 02:57 AM
Surely, there is no precedence issue. If it is protected, and you unprotect it, it becomes unprotected.

Aussiebear
04-17-2007, 01:12 AM
G'day Bob,

I had some code which removed the sheet protection, did its magic, then reset the protection. Trouble was when I manually removed the sheet protection and then clicked on a cell to view the formula, it suddenly reprotected itself.

My solution to this is that every section of code that ran on that particular sheet now has a remove/ reset protection in every section of code.

Bob Phillips
04-17-2007, 02:11 AM
Surely, that means that you have event code that is automatically setting that protection on.

You could add a button that disables/enables events and click that before you do your manual but, then click after.

Aussiebear
04-17-2007, 03:02 AM
its working fine,besides its at work and given their recent statement in the employee handbook.... well I'm not modifing any code any further.