Sub ProtectAll()
Sheet4.Protect Password:="xx2016"
End Sub
Please help improve code to only lock one worksheet
Sub ProtectAll()
Sheet4.Protect Password:="xx2016"
End Sub
Please help improve code to only lock one worksheet
It would be great if you could provide more information about your actual problem. I guess, that you want to lock a specific cell but if you lock the sheet, all cells are locked. If this is so, here is the solution. If not, please explain your problem!
First of all you need to change the "Locked" attribute for all cells to false (default is true). Then, you selt the "Locked" attribute to true for all required cells. Then, you can lock the sheet.
Sub Makro2()
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("E6").Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("E4").Select
End Sub
Edit 1: Thanks to Pav, here is a better solution that avoids "selects" but is working in the same way:
Sub Makro2()
Cells.Locked = False
Cells.FormulaHidden = False
Range("E6").Locked = True
Range("E6").FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="xx2016"
End Sub