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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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
 
Upvote 0
The Code disable the paste command in Excel only. You can copy data (Edit - Copy) and paste data in Words or others application.
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

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
Back
Top