View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
John Wilson John Wilson is offline
external usenet poster
 
Posts: 550
Default delete all but protected cells

Kingtriton,

why wont it clear the contents of the unlocked cells when the sheet is

protected?
The simple answer is because the sheet is protected.

Two options.......
If the sheet is manually password protected, unprotect it before you
run the code and reprotect it afterwards.

or...................

Use this code (modify to suit) in the Workbook_Open event:

Worksheets("yoursheetname") Protect Password:="yourpassword", _
UserInterfaceOnly:=True

The above will protect the worksheet but allow it to be modified via code.
It has to be set each time the workbook opens. The "protect" will stick
on close/reopen but the "UserInterfaceOnly" won't.

John




"Kingtriotn " wrote in message
...
That clears the contents of all unlocked cells but only if the sheet is
not protected. This is where I keep running into walls, why wont it
clear the contents of the unlocked cells when the sheet is protected?
Thanks again,
Kingtriton


---
Message posted from http://www.ExcelForum.com/