ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   worksheet protection (https://www.excelbanter.com/excel-programming/274869-worksheet-protection.html)

Todd[_5_]

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
.



All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com