Okay that means there are no formulae in that particular worksheet.
Try this code
Option Explicit Sub LockFormulae() Dim rngHasFormula As Range Dim ws As Worksheet On Error Resume Next For Each ws In ActiveWorkbook.Worksheets ws.Unprotect Set rngHasFormula = ws.UsedRange.SpecialCells(xlCellTypeFormulas) If Err.Number <> 0 Then Err.Clear Else With rngHasFormula .Locked = True .FormulaHidden = True End With End If ws.Protect Next On Error GoTo 0 End Sub
Bookmarks