unprotect a worksheet


Posted by cindy on July 10, 2001 8:00 AM

the workbook that i am using contains formulas and vba procedures (macros).. the workbook and certain sheets are protected on load.. but there is an command button that runs a solver..how can i unprotect the worksheet so that the solver solutions can be uploaded.. note that the worksheet.unprotect is not working thanks please answer asap.. i have a deadline to beat

Posted by JAF on July 10, 2001 8:23 AM

It sounds like the worksheet that is protected has a password on it.

Put the following lines at the start and the end of the code that runs the solver:

Sub run_the_solver()
ActiveSheet.Unprotect Password:="YOURPASSWORDHERE" 'start of solver macro
'
'your existing macro code here...
'
ActiveSheet.Protect Password:="YOURPASSWORDHERE" 'end of solver macro
End Sub
That should do the trick.


JAF

Posted by cindy on July 10, 2001 8:31 AM

i've used the code
activesheet.unprotect, password ="" (since that was the password used)

that was used when the Run Solver button is clicked but i got the error 1004.. how can i eliminate this

Posted by David on July 10, 2001 11:55 AM

If you protect the sheets on load and specify "UserInterfaceOnly" then macros, etc will be able to run unhindered.

Posted by cindy on July 10, 2001 10:53 PM

private sub workbook_open()
Worksheets("Ingredients").Protect Password:="", DrawingObjects:=True, _
Contents:=True, UserInterfaceOnly:=True
end sub

can run the solver but the constraints are not satisfied and the result is zero.

when i unprotect a worksheet i get a 1004 or 450 error.. help pleaase.. my deadline is tom..

thanks.. david..

please attach the codes here thanks



Posted by cindy on July 10, 2001 11:33 PM

error is unprotct method of worksheet class failed err.number = 1004

help please... i have a deadline