Locked cells

  • Thread starter Thread starter Amy
  • Start date Start date
Hi Amy

Selection.Locked = True

Selection.Locked = False

Or

Range("A1:c10").Locked = True


Or all cells on the worksheet

Cells.Locked = True
 
okay this is what I have:
Private Sub Workbook_Open()
'check for filter, turn on if none exists
With Worksheets("worksheet")
If Not .AutoFilterMode Then
.Range("A2").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="password", _
Contents:=True, UserInterfaceOnly:=True
Range("C:C,D:D,L:L").Selec
Selection.Locked = True
End With
End Sub

it doesn't lock the cells.... any ideas?
 
Change the locked before you protect the sheet

Try this

Private Sub Workbook_Open()
'check for filter, turn on if none exists
With Worksheets("worksheet")
If Not .AutoFilterMode Then
.Range("A2").AutoFilter
End If
.Range("C:C,D:D,L:L").Locked = True
.EnableAutoFilter = True
.Protect Password:="password", _
Contents:=True, UserInterfaceOnly:=True
End With
End Sub
 
Back
Top