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
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
If you protect the sheets on load and specify "UserInterfaceOnly" then macros, etc will be able to run unhindered.
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
error is unprotct method of worksheet class failed err.number = 1004
help please... i have a deadline