|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
在EXCEL对象Sheet1下输入
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
Selection.SpecialCells(xlCellTypeFormulas, 23).Locked = True '锁定所有含公式单元格
Selection.SpecialCells(xlCellTypeConstants, 23).Locked = True '锁定所有常量单元格
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Target.Select
Application.ScreenUpdating = True
End Sub
如需打开文件保护,执行宏myUnprotect
Sub myUnprotect()
ActiveSheet.Unprotect
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
[a1].Select
End Sub
详见附件文件 |
|