MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How do I protect indivdiual cells?


Posted by dalton on December 30, 2001 10:15 AM

I have cells with text and formulas that I do not want to delete. How can I protect them and do a select all, for example, and clear all the unprotected cells.
Thanks.
ed


Posted by Dank on December 30, 2001 12:55 PM

There may be an easier or quicker way than this. I first thought that the SpecialCells method would be the way but alas, no. This macro clears all unlocked cells on the active sheet. The line Application.Screenupdating speeds up the macro by about 20%. Hope it helps, Dan.

Sub DeleteUnlockedCells()
Dim rngeCell As Range
Application.ScreenUpdating = False

For Each rngeCell In ActiveSheet.UsedRange.Cells
If rngeCell.Locked = False Then rngeCell.ClearContents
Next
Application.ScreenUpdating = True
End Sub