Hi i have put together a excel VBA code that works in parts,
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
If ActiveSheet.ProtectContents = False Then
Exit Sub
End If
Target.PasteSpecial xlPasteValues
Application.CutCopyMode = True
End Sub
stops unprotected sheets from copy paste, so that it pastes values only, only problem i have with this one is that as soon as you click somewhere it pasts the values, I can live with that but would be nice if anyone also knew a fix for that.
then i have this code:
Private Sub Workbook_Activate()
If ActiveSheet.ProtectContents = False Then
Application.CellDragAndDrop = True
Exit Sub
End If
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
If ActiveSheet.ProtectContents = False Then
Application.CellDragAndDrop = True
Exit Sub
End If
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If ActiveSheet.ProtectContents = False Then
Application.CellDragAndDrop = True
Exit Sub
End If
Application.CellDragAndDrop = False
End Sub
Display More
to stop drag and drop from being used and messing upp code in unprotected sheets.
They work fine on their own, but as soon as i put them both into the workbook, the copy paste one is broken in the way that you can no longer copy past on to other sheets/workbooks. It only works on the same sheet.
Anyone got a fix for that?
I have these to protect condition formatings and codes from being messed upp by other users.
But They need to be able to copy paste values inside the workbook and to other workbooks