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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top