View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Is there a way to prevent pasting data into an Excel worksheet

Did you put the code behind ThisWorkbook?

If no, then delete it from where you put it and put it under ThisWorkbook.

Rod from Corrections wrote:

Elkar, thanks so much for trying to help me. It's nice to know that there
may be a solution to my problem. Unfortunately, when I tried what you
suggested, it had no effect - cut and paste was still allowed.

I know nothing about using Virtual Basic, but did a bit of research. I
tried the debug command and it reflected some syntax errors, which I then
tried to fix.

I ended up with the following in the VB Editor, but it still had no effect.
Can you help? Please be very explicit in your directions, since I am a
complete novice with VB. Thanks!

Private Sub Worksheet_Activate()
Select Case Application.CutCopyMode
Case Is = False
MsgBox "Not in Cut or Copy mode"
Case Is = xlCopy
MsgBox "In Copy mode"
Case Is = xlCut
MsgBox "In Cut mode"
End Select
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
Select Case Application.CutCopyMode
Case Is = False
MsgBox "Not in Cut or Copy mode"
Case Is = xlCopy
MsgBox "In Copy mode"
Case Is = xlCut
MsgBox "In Cut mode"
End Select
End Sub

"Elkar" wrote:

I've run into this problem myself. It can be solved quite simply with just a
few lines of VB Code. Add this code to your workbook (use Alt-F11 to open
the VB Editor, then double-click "ThisWorkbook", then copy/paste the below
code)

Private Sub Workbook_Activate()
Application.CutCopyMode = None
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Application.CutCopyMode = None
End Sub


NOTE: If the user disables macros when the workbook is opened, then this
won't work.

HTH,
Elkar



"Rod from Corrections" wrote:

I work in a correctional centre. Some of the correctional officers have
little training to use Excel or other programs, but are required to complete
spreadsheets on line. Although we have heavily protected the worksheets and
locked cells, we find that in some cases the staff can still mess up the
worksheets by copying and pasting data inappropriately.

Is there a way to turn off the ability to paste data into the worksheet, and
to force each field to be completed manually? This would eliminate the
problem.


--

Dave Peterson