我正在使用以下代码在 excel 中构建一个工具并保护了工作簿,因此不允许删除或插入行/列:
Sub ProtectSheet()
ActiveSheet.Protect _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowInsertingHyperlinks:=True, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowUsingPivotTables:=True, _
Password:=cPassword
End Sub
但是,如果用户尝试删除或插入告诉他们无法执行此操作并提供其他说明的行/列,我还希望出现一个消息框。谁能建议我如何做到这一点?
谢谢!