我有以下代码来保护我的工作表
Sub Lock_RESULT_SHEET ()
Application.ScreenUpdating = False
Sheets("RESULT").Select
ActiveSheet.Unprotect Password:="ABCD"
ActiveSheet.Cells.Locked = False
ActiveSheet.Range("A3:E5000").Locked = True
ActiveSheet.Protect Password:="ABCD", Contents:=True, DrawingObjects:=False, UserInterfaceOnly:=True, _
AllowFormattingCells:=True, AllowFiltering:=True, AllowSorting:=True,AllowInsertingRows:=True,AllowInsertingColumns:=True
END SUB
##问题是什么? ##在此代码中,我确实允许行和列插入,但是在我插入时,警告弹出窗口显示“您要更改的单元格或图表在受保护的工作表上” VBA专家,请帮助我。预先谢谢你。
答案 0 :(得分:0)
这应该是您需要添加的所有内容,如之前@Jeeped所述。确保您在Application.X = False
下标记的内容最终设置回= True
Sub Lock_RESULT_SHEET ()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("RESULT").Select
ActiveSheet.Unprotect Password:="ABCD"
ActiveSheet.Cells.Locked = False
ActiveSheet.Range("A3:E5000").Locked = True
ActiveSheet.Protect Password:="ABCD", Contents:=True, DrawingObjects:=False, UserInterfaceOnly:=True, _
AllowFormattingCells:=True, AllowFiltering:=True, AllowSorting:=True,AllowInsertingRows:=True,AllowInsertingColumns:=True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
END SUB