ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   disallowing copying of rows (https://www.excelbanter.com/excel-programming/370589-disallowing-copying-rows.html)

[email protected]

disallowing copying of rows
 
Is it possible to disallow copying of rows.
I just dont want a row to be copied and pasted, can anyone tell me how
to do that.
I am just trying to avoid the duplicate entries associated with a row.
For example, if rows are assigned a unique value(i have used validation
option), and then if someone copy and paste the value it allows it to
do so. In order to avoid that, I want to restrict a user to go for
copying a row and pasting it elsewhere.
Someone please help,
Regards,
Nasir.


NickHK

disallowing copying of rows
 
Try this. You can't stop the Copy, but you can stop the Paste.
Depending on your needs, you can a check of the Target invloved, to see if
it is allowed or not.

Dim Cutting As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Msg As String

With Application
Select Case .CutCopyMode
Case False
If Cutting Then
Msg = "Was Cut"
Else
Msg = "Normal Entry"
End If
Case xlCopy
Msg = "Pasted Copy"
.EnableEvents = False
.Undo
.EnableEvents = True
End Select
End With
MsgBox Msg

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cutting = (Application.CutCopyMode = xlCut)
End Sub

NickHK

wrote in message
oups.com...
Is it possible to disallow copying of rows.
I just dont want a row to be copied and pasted, can anyone tell me how
to do that.
I am just trying to avoid the duplicate entries associated with a row.
For example, if rows are assigned a unique value(i have used validation
option), and then if someone copy and paste the value it allows it to
do so. In order to avoid that, I want to restrict a user to go for
copying a row and pasting it elsewhere.
Someone please help,
Regards,
Nasir.




[email protected]

disallowing copying of rows
 
Nick, I understand what u mean. Thanks for the help, however, the code
is not working. Any suggestion?


NickHK wrote:
Try this. You can't stop the Copy, but you can stop the Paste.
Depending on your needs, you can a check of the Target invloved, to see if
it is allowed or not.

Dim Cutting As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Msg As String

With Application
Select Case .CutCopyMode
Case False
If Cutting Then
Msg = "Was Cut"
Else
Msg = "Normal Entry"
End If
Case xlCopy
Msg = "Pasted Copy"
.EnableEvents = False
.Undo
.EnableEvents = True
End Select
End With
MsgBox Msg

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cutting = (Application.CutCopyMode = xlCut)
End Sub

NickHK

wrote in message
oups.com...
Is it possible to disallow copying of rows.
I just dont want a row to be copied and pasted, can anyone tell me how
to do that.
I am just trying to avoid the duplicate entries associated with a row.
For example, if rows are assigned a unique value(i have used validation
option), and then if someone copy and paste the value it allows it to
do so. In order to avoid that, I want to restrict a user to go for
copying a row and pasting it elsewhere.
Someone please help,
Regards,
Nasir.



NickHK

disallowing copying of rows
 
I suggest you provide a bit more explanation to "the code is not working" .

NickHK

wrote in message
ups.com...
Nick, I understand what u mean. Thanks for the help, however, the code
is not working. Any suggestion?


NickHK wrote:
Try this. You can't stop the Copy, but you can stop the Paste.
Depending on your needs, you can a check of the Target invloved, to see

if
it is allowed or not.

Dim Cutting As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Msg As String

With Application
Select Case .CutCopyMode
Case False
If Cutting Then
Msg = "Was Cut"
Else
Msg = "Normal Entry"
End If
Case xlCopy
Msg = "Pasted Copy"
.EnableEvents = False
.Undo
.EnableEvents = True
End Select
End With
MsgBox Msg

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cutting = (Application.CutCopyMode = xlCut)
End Sub

NickHK

wrote in message
oups.com...
Is it possible to disallow copying of rows.
I just dont want a row to be copied and pasted, can anyone tell me how
to do that.
I am just trying to avoid the duplicate entries associated with a row.
For example, if rows are assigned a unique value(i have used

validation
option), and then if someone copy and paste the value it allows it to
do so. In order to avoid that, I want to restrict a user to go for
copying a row and pasting it elsewhere.
Someone please help,
Regards,
Nasir.






All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com