PDA

View Full Version : User must fill in certain cells before they can close the workbook



glenn0004
07-23-2014, 03:12 AM
Hi have been using the following artical (vbaexpress.com/kb/getarticle.php?kb_id=587) to to ensure that mandatory cells are completed, however I now have a need to protect a range of cells that are non editable within a sheet that the code applies. However, once protected I get an error. Can any one advise.

ranman256
07-23-2014, 10:06 AM
What is the error?

glenn0004
07-23-2014, 12:43 PM
What is the error?

Thanks for getting back to me - Run time error "1004" Application defined or object defined-error.12015

westconn1
07-24-2014, 04:53 AM
try like

Cell.Parent.Unprotect pwd
Cell.Interior.ColorIndex = 6 '** color yellow
Cell.Parent.Protect pwd

glenn0004
07-24-2014, 08:59 AM
try like

Cell.Parent.Unprotect pwd
Cell.Interior.ColorIndex = 6 '** color yellow
Cell.Parent.Protect pwd

Thank for taking the time to help - I assume that pwd is the password applicable to the sheet.
On repacing the sample section of the VBA this give me run time error 1004 and an advisory that I have a password mismatch - a debug highlights that the issue is within Cell.Parent.Unprotect pwd.

westconn1
07-24-2014, 02:10 PM
password mismatchare you passing the password as a literal or variable?
are you sure it is correct?
it worked on testing
cell.parent is the worksheet, so you could try the sheet object, but it should be the same thing