I need to write some vba to allow users to insert new rows/columns but not allow them to delete them. I cannot protect the workbook as all users have the rights to unprotect the workbook.
I found the code below which works great for not allowing users to delete but does not allow inserting rows/columns either. Can anyone help.
I found the code below which works great for not allowing users to delete but does not allow inserting rows/columns either. Can anyone help.
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If ((Target.Address = Target.EntireRow.Address Or _
Target.Address = Target.EntireColumn.Address)) Then
With Application
.EnableEvents = False
.Undo
MsgBox "No deleting rows or columns", 16
.EnableEvents = True
End With
Else
Exit Sub
End If
End Sub