I am trying to lock down this workbook and all worksheets from users making accidental or intentional changes to ANYTHING except specific cells for date or text entry and also data entry through the userforms activated from form buttons and command buttons.
I have locked off cut/copy/paste, right-clicking, I have designed the worksheets and workbook to automatically lock every time the workbook is closed.
But there are still changes people can make. For example FORMATTING. They can still Clear Formats using the menu bar button, they can Fill Down, Right, Up, Left. Also, the Formulas tab is FULL of active buttons that can make undesirable changes. I don't want users to be able to make ANY CHANGES except to cells I have left unlocked and changes made through userforms from form/command buttons. Below is some of the code I use to lock off changes. Any help appreciated!
I have locked off cut/copy/paste, right-clicking, I have designed the worksheets and workbook to automatically lock every time the workbook is closed.
But there are still changes people can make. For example FORMATTING. They can still Clear Formats using the menu bar button, they can Fill Down, Right, Up, Left. Also, the Formulas tab is FULL of active buttons that can make undesirable changes. I don't want users to be able to make ANY CHANGES except to cells I have left unlocked and changes made through userforms from form/command buttons. Below is some of the code I use to lock off changes. Any help appreciated!
Code:
Private Sub Workbook_Activate()Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.OnKey "^v"
Application.CutCopyMode = False
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.OnKey "^v"
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right click menu deactivated." & vbCrLf & _
"Cannot copy or ''drag & drop''.", 16, "For this workbook:"
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub