Dailycode.info

Short solution for short problems

Unprotected Cells on a Protected worksheet

I was looking for a good way to set some cells editable in Excel in a worksheet that is completely protected. 

I call a function at the end of the action that protects the entire sheet:

Public Sub ProtectSheet(sWorkSheet As String)

 Worksheets(sWorkSheet).Protect Password:=XXxxXXxx, AllowFiltering:=True

End Sub

Now to prevent some cells to be protected, you just need to set the cells to Locked = False before you protect the worksheet.

'Make sure this cell doesn't get protected when you protect the sheet.

 Cells(iCnt, 3).Locked = False