protecting and unprotecting using a macro


Posted by Krista on November 03, 2000 6:18 AM

I am trying to write VBA code in a macro form to accept user input into a message box only. The code is to be the only method of changing values in the worksheet - i.e. the user cannot select a cell and change the value.

How can I use the macro code to unprotect the sheet in order to change the values, then re-protect it after the calculations are complete? Is there a way to protect the sheet from user changes, but not from macro changes? (I have gotten the macro to protect the sheets, but I can't get the code to unprotect it.)

Posted by Ben O. on November 03, 2000 6:54 AM

How about:

Activesheet.Unprotect(password)

or

Sheets("Name").Unprotect(password)

The password variant is ignored if your worksheet isn't password-protected.

-Ben



Posted by Ivan Moala on November 03, 2000 1:11 PM


to protect the sheet from user changes, but not from macro changes have a look @ online hlp
for Protect Userinterfaceonly

Ivan