MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How can i protect the worksheet using VBA codes after a solver run?

Posted by cindy on July 26, 2001 8:18 PM

I am running the solver in two ways:

1. is through a vba code -- this is working
2. by clicking the Solver command on the tools menu.. prior to the solver run, the sheet is protected and i have to unprotect it, so that i can run the solver, after the solver run it should be protected using vba codes.. how can i do this?

worksheets ("a") = protect

sub unprotect_button_click()
worksheets ("a").unprotect

by this time i can manually add additional constraints to the solver on the tools menu..
after the solver run how can i protect the sheet once more?
is there a function that will tell that the solver has finished running?

thanks.. i need help ASAP.. deadline is on monday

Posted by steve w on July 26, 2001 9:34 PM

try this
Me.Unprotect Password:=""
Me.protect Password:=""
place it at beginging and the end of the code