- Codice: Seleziona tutto
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim formula As Range
On Error Resume Next
Sh.Unprotect Password:="password"
With Selection
.Locked = False
.FormulaHidden = False
End With
If Target.Cells.Count = 1 Then
If Target.HasFormula Then
With Target
.Locked = True
.FormulaHidden = True
End With
Sh.Protect Password:="password", UserInterFaceOnly:=True
End If
ElseIf Target.Cells.Count > 1 Then
Set formula = Selection.SpecialCells(xlCellTypeFormulas)
If Not formula Is Nothing Then
With Selection.SpecialCells(xlCellTypeFormulas)
.Locked = True
.FormulaHidden = True
End With
Sh.Protect Password:="password", UserInterFaceOnly:=True
End If
End If
On Error GoTo 0
End Sub
l'ho inserita in thisworkbook e in effetti nasconde le formule nelle varie celle. Il problema è che quando mi posiziono su una cella dove non ci sono formule si blocca il file.
Sicuramente c'è qualcosa che non funziona in questa macro.Per cortesia mi potete risolvere questo problema.
Grazie in anticipo e buona serata.