worksheet protection

T

Todd

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
 
Top