Good day
I have been researching this for 3 days now with no luck
The below is the closest I got but it comes up with a debug for cel.Locked=true
The error is:
Run-time error '1004':
Unable to set the locked property of the Range class
Sub ProtectAll()
Dim sht As Worksheet
Dim cel As Range
Dim twb As Workbook
Set twb = ThisWorkbook
For Each sht In twb.Sheets
For Each cel In sht.UsedRange
If cel.HasFormula = True Then
cel.Locked = True
Else
cel.Locked = False
End If
Next cel
sht.Protect "Password"
Next sht
End Sub
Sub UnProtectAll()
Dim sht As Worksheet
Dim twb As Workbook
Set twb = ThisWorkbook
For Each sht In twb.Sheets
sht.Unprotect "Password"
Next sht
End Sub
I need to password protect all formulas in all the sheets for a workbook, and then be able to unprotect it if changes needs to made by using the same password used to protect it
Please help
Bookmarks