Hi
I have the following code that disables cutting and pasting (so as to avoid formatting being messed up, especially conditional formatting).
I also have the following code that, if a user copies and attempts to paste, it changes the paste to Paste Special Values (again to avoid formatting being messed up):
However, I don't want the first piece of code to fire if the user is cutting an entire row and inserting the row in a different position. I only want it to fire if the user is attempting to cut a particular range of cells.
Can anyone tell me if it's possible and what modification of the code is required?
Thanks
Liam
I have the following code that disables cutting and pasting (so as to avoid formatting being messed up, especially conditional formatting).
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case Application.CutCopyMode
Case Is = False
Case Is = xlCopy
Case Is = xlCut
Application.CutCopyMode = False
End Select
End Sub
I also have the following code that, if a user copies and attempts to paste, it changes the paste to Paste Special Values (again to avoid formatting being messed up):
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.CutCopyMode = xlCopy Then
With Application
.ScreenUpdating = False
.EnableEvents = False
.Undo
Target.PasteSpecial Paste:=xlPasteValues
.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub
However, I don't want the first piece of code to fire if the user is cutting an entire row and inserting the row in a different position. I only want it to fire if the user is attempting to cut a particular range of cells.
Can anyone tell me if it's possible and what modification of the code is required?
Thanks
Liam