保护工作表后,锁定才起作用。所以应解除第一列的锁定,再保护工作表。然后Alt+F11,将下面代码粘贴到某个工作表处。
Private Sub Worksheet_Change(ByVal Target As Range)If Target.Column = 1 ThenActiveSheet.UnprotectRange("A:A")
.SelectIf Cells(Target.Row, Target.Column) = "
" ThenSelection.Locked = FalseElseSelection.Locked = TrueCells(Target.Row, Target.Column).Locked = FalseEnd IfCells(Target.Row, Target.Column)
.SelectActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=TrueEnd IfEnd Sub程序修改的是A列
- 相关评论
- 我要评论
-