I am building a tool in excel and have protected the workbook so that deleting or inserting rows/columns is not allowed, using the code below:
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
However, I also want a message box to appear if the user tries to delete or insert a row/column that tells them they cannot do this and provides other instructions. Can anyone advise me on how to do this?
Thanks!