Copying cells in Excel

skartha

New Member
Joined
Sep 10, 2002
Messages
4
Can somebody help me, urgently!! I want to stop the user from copying cells in excel. and also pasting of data from outside excel.

I think some macro shud be used here. Perhaps on right_click of mouse, the clipboard.clear should be fired. this will stop the user from pasting in the cells that have some important data.

Please help.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,257
Placing this in your workbook module would be a start, but there's no guarantee that a determined person will try to circumvent whatever obstacles are imposed. This code will deter your friends:

Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.CellDragAndDrop = 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 file:"
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.CutCopyMode = False
End Sub
Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CutCopyMode = False
End Sub
 

JayMenon

New Member
Joined
Aug 21, 2002
Messages
19
Hi !

You may use the Tools|Protection to protect your sheet or cells !!

Regards
 

Emily

Active Member
Joined
Aug 28, 2002
Messages
304
The Code disable the paste command in Excel only. You can copy data (Edit - Copy) and paste data in Words or others application.
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,257
You raise a good point Emily. As I said, it's difficult to prevent some Windows procedures. Adding code such as the following will help in Excel but still have limited effectiveness where other programs are concerned:

Application.CommandBars("Clipboard").FindControl(ID:=3634).Execute
or
Application.CopyObjectsWithCells = False

Also, it is possible to enter paste-link formulas in other Excel workbooks and reproduce data from the "protected" app. Plenty of ways to get around the protection and clipboard clearing routines, unfortunately.
 

Tommy Bak

Active Member
Joined
Feb 25, 2002
Messages
288
Hi
As Tom writes it nearly impossimble to prevent copying to other application, but you cuold protect the cells you do not want to be copied and the in the sheets own module paste this code.
it will prevent the user from selecting the cells at all

Private Sub Worksheet_Activate()
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub

regards tommy
 

Forum statistics

Threads
1,143,920
Messages
5,721,541
Members
422,369
Latest member
redinator

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top