View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Todd[_5_] Todd[_5_] is offline
external usenet poster
 
Posts: 28
Default worksheet protection

I found a macro in the archives! But I am having trouble
running it. I get the message "unable to set locked
property of the range class". Where am I going wrong????
The debugger doesn't like the else: statement


Thanks again,

Todd



Sub ProtFormula()

Dim cell As Range
Dim sht As Worksheet

Application.ScreenUpdating = False
For Each sht In Worksheets
sht.Activate
For Each cell In sht.UsedRange
If cell.HasFormula = True Then
cell.Locked = True
cell.FormulaHidden = False
Else: cell.Locked = False
End If
Next cell
Next sht
Application.ScreenUpdating = True

End Sub


-----Original Message-----
Is there a way to select all cells without a formula and
unlock them? Maybe a macro? I want to protect all the
cells with formulas and leave the rest open to changes.
Right now all cells with data are locked. I have a lot
of worksheets so doing this manually will take a LONG

time.


TIA

Todd
.