excel - 在保护工作表中允许插入行和列,但仍然弹出警告消息,如何阻止?
问题描述
我有以下代码来保护我的工作表
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 专家,请帮助我。先感谢您。
解决方案
正如@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
推荐阅读
- tabulator - 有没有办法在制表符的列中按单元格或按行设置“选择”选项?
- android - 如何在 Android API 级别 29 (>= 29) 及以上以编程方式连接到其他 Wi-fi 网络
- javascript - 模态没有出现反应-boostrap
- android - 增加 ImageView 的可点击区域
- matlab - 如何在matlab中求解线性符号方程
- amazon-web-services - 使用 terraform 部署 EKS 节点组时出错
- clojure - Clojure函数不返回地图
- shopify - 我的动态购物车属性 - 第二个属性为每个订单显示相同的值
- python - 如何在 for 语句中使 work 成为一个函数?
- google-apps-script - 谷歌应用脚本 v8 中的保护失败