Selected Answer
It seems to me that the code you are using represents a bit of an over-kill in that it treats all sheets in the workbook equally. Please try the code below. Install it in the code sheet of the worksheet on which you want the action. I think it will have the same functionality you already know. If not, tell me where I'm wrong. It will not balk at merged cells/
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' 27 Oct 2017
Const Pw As String = "password"
Dim CellsWithFormula As Range
Dim n As Long
With Target
On Error Resume Next
n = .Cells.Count
' if the entire sheet is selected,
' only the first cell's merge area will be processed
If Err Then Set Target = .Cells(1).MergeArea
On Error GoTo 0
End With
With Target
Set CellsWithFormula = .SpecialCells(xlCellTypeFormulas)
If Not CellsWithFormula Is Nothing Then
Unprotect Password:=Pw
With CellsWithFormula
.Locked = True
.FormulaHidden = True
End With
Protect Password:=Pw, UserInterFaceOnly:=True
End If
End With
End Sub
As for the cell you wish to excclude, the description of it you give is insufficient. The best way to identify it would be by its location. If it's a range, then the range's location. If it must be identified by the formula it holds, the exact formula is needed, as it appears in the cell, including $ signs.