PDA

View Full Version : Protected Sheet and Data Validation



clew
01-11-2011, 08:36 AM
I'm having a problem with running some code on a protected sheet. The code in question handles the data validation for particular cells when they are selected. I initially got run-time errors because the macros were protected, so I used the worksheet.protect method and the UserInterfaceOnly argument:

Sheets("7. Equip Schedule").Protect "password", userinterfaceonly:=True
This did not work at first, but I then learned that data validation uses drawing objects, so I tried:


Sheets("7. Equip Schedule").Protect "password", userinterfaceonly:=True, DrawingObjects:=False
This worked, sort of. My code runs properly and updates cell data validation as desired. However, despite the sheet being protected, cells which are locked are still editable by the user. So it's essentially not protected. I tried:


Sheets("7. Equip Schedule").Protect "password", Contents:= True, userinterfaceonly:=True, DrawingObjects:=False
This fixes the protection of locked cells but the run-time errors return.

Has anyone experienced a similar issue? Any suggestions?

Thanks.

austenr
01-11-2011, 03:07 PM
It might help if you posted the whole code. Snippets are hard to debug.