Hello, I would like to deny pasting into certain columns (F:G) without disrupting that ability elsewhere.
I've searched for this and have come close to a solution, but they haven't been quite right.
I used the following but it restricts pasting for the entire sheet
[FONT="]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/FONT]
[FONT="] Application.CutCopyMode = False[/FONT]
[FONT="]End Sub
I have tried this as well. It prevent copy and pasting within the sheet, but once I copy from a separate sheet or workbook, it allows the pasting to occur.
[/FONT][FONT="]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/FONT]
[FONT="] If Intersect(Target,Range("F:G")) Is Nothing Then Exit Sub[/FONT]
[FONT="] Application.CutCopyMode = False
End Sub[/FONT]
[FONT="]
I tried using the above with the following and the result is the same. I can prevent copy and paste from within the sheet, but it still allows copy and pasting between sheets or from an entirely separate workbook.
I obtained all of these from answers.microsoft.com and admittedly my understanding of this is basically nil.
From within Mr.Excel (courtesy of @Tom Urtis) I found the following, but the results were no more encouraging. When I applied this to my workbook, either I did it wrong (entirely probable) or something is missing, as it had no effect on copy and pasting at all:
[/FONT]Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
Application.OnKey "^c"
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.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub[FONT="]
[/FONT]Again, I don't wish to totally deny copy & paste. I want to prevent its use in certain columns within a sheet.
Thanks in advance for any help anyone can provide.
I've searched for this and have come close to a solution, but they haven't been quite right.
I used the following but it restricts pasting for the entire sheet
[FONT="]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/FONT]
[FONT="] Application.CutCopyMode = False[/FONT]
[FONT="]End Sub
I have tried this as well. It prevent copy and pasting within the sheet, but once I copy from a separate sheet or workbook, it allows the pasting to occur.
[/FONT][FONT="]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/FONT]
[FONT="] If Intersect(Target,Range("F:G")) Is Nothing Then Exit Sub[/FONT]
[FONT="] Application.CutCopyMode = False
End Sub[/FONT]
[FONT="]
I tried using the above with the following and the result is the same. I can prevent copy and paste from within the sheet, but it still allows copy and pasting between sheets or from an entirely separate workbook.
I obtained all of these from answers.microsoft.com and admittedly my understanding of this is basically nil.
From within Mr.Excel (courtesy of @Tom Urtis) I found the following, but the results were no more encouraging. When I applied this to my workbook, either I did it wrong (entirely probable) or something is missing, as it had no effect on copy and pasting at all:
[/FONT]Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
Application.OnKey "^c"
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.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub[FONT="]
[/FONT]Again, I don't wish to totally deny copy & paste. I want to prevent its use in certain columns within a sheet.
Thanks in advance for any help anyone can provide.