Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Claudio.
Vorrei proteggere solo determinate celle di un Foglio di Lavoro , utilizzo questo codice trovato in rete e adattato , Funziona .... ma protegge tutte le Celle del Foglio , il codice e' questo
Dim MRng1 As Range
Dim Cell As Range
Set MRng1 = Range("G2,I2,C3:I3,G17,I17,C18:I18,G32,I32,C33:I33,G47,I47,C48:I48,G62,I62,C63:I63")
For Each Cell In MRng1
If Cell.Value <> "" Then
Cell.Locked = True
End If
ThisWorkbook.Worksheets("GENNAIO").Protect
Next Cell
Dove sbaglio ??? cosa manca ??
Prova qualcosa del genere:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim MRng1 As Range
Dim Cell As Range
With ThisWorkbook.Worksheets("GENNAIO")
Set MRng1 = _ .Range("G2,I2,C3:I3,G17,I17,C18:I18,G32,I32,C33:I33,G47,I47,C48:I48,G62,I62,C63:I63")
.Unprotect
.Cells.Locked = False
For Each Cell In MRng1.Cells
If Cell.Value <> "" Then
Cell.Locked = True
End If
Next Cell
.Protect
End With
End Sub
'<<=========
Comunque, per prottegere solo le formule, meglio sarebbe:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim MRng1 As Range
Dim Cell As Range
With ThisWorkbook.Worksheets("GENNAIO")
On Error Resume Next
Set MRng1 = _ .Range("G2,I2,C3:I3,G17,I17,C18:I18,G32,I32,C33:I33,G47,I47,C48:I48,G62,I62,C63:I63") _
.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0
If Not MRng1 Is Nothing Then
.Unprotect
.Cells.Locked = False
For Each Cell In MRng1.Cells
If Cell.Value <> "" Then
Cell.Locked = True
End If
Next Cell
End If
.Protect
End With
End Sub
'<<=========
===
Regards,
Norman