Disable PASTE in an Excel sheet

Octonet

New Member
Joined
Sep 5, 2020
Messages
27
Office Version
  1. 2019
Platform
  1. Windows
Hello everybody,
I have a workbook that has different sheets.
Now there are some sheets were I want to disable only the paste function?
I searched the net, but could only find a solution to disable copy/paste.
I need the copy function, but I like to disable the paste function.
I think this can only be done by a VBA script, but that's OK for me.
Who can help ???
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Bebo021999,

Good question :)
The workbook is a workbook I made to read the results of a coating thickness meter in the automotive industry.
To prevent people from cheeting, pasting results from a random generator, I want to disable the paste function in some sheets.
The copy function I still need to copy measurement results from the sheet to other sheets in the workbook.
I hope this answers your question.
 
Upvote 0
This code to prevent copy data from other sheet or from other program, into sheet3 and sheet4.
Every time sheet3 or sheet4 is activate, it make a new "copy" a random cell (i.e, cell A3), but not paste, then turn off CutCopyMode.
It is placed in ThisWorkbook project.
Note : After sheet_activate, Copy and Paste within sheet is active .
Is it are you looking for?
VBA Code:
Option Explicit
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ExSh As String
Set Sh = ActiveSheet
ExSh = ",Sheet3,Sheet4," ' list of sheets with "paste" is disable. Add more. Or change it to actual sheet name
    If ExSh Like "*," & Sh.Name & ",*" Then
        Sh.Range("A3").Copy
        Application.CutCopyMode = False
    End If
End Sub
 
Upvote 0
Hello Bebo021999,
I copied the VBA sub into Microsoft Excel objecs\this workbook and changed the names of the sheets. I still can copy from another workbook to the selected sheets.
 
Upvote 0
What are the sheet names? And what is current code, after sheet names were applied?
 
Upvote 0
Option Explicit
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ExSh As String
Set Sh = ActiveSheet
ExSh = "importF48,importF56,importF60" ' list of sheets with "paste" is disable. Add more. Or change it to actual sheet name
If ExSh Like "*," & Sh.Name & ",*" Then
Sh.Range("A1").Copy
Application.CutCopyMode = False
End If
End Sub

This is the only code that is in "this workbook".
Example : If importF48 is applied, The sheet reads the data from the meter into a table. After that, nothing happens and I must choose to process these data. But between reading data and process data nothing happens.
 
Upvote 0
With this line:
Code:
If ExSh Like "*," & Sh.Name & ",*" Then
we are searching for ",importF48," (with "," before and after sheetname)
So:
Code:
ExSh = "importF48,importF56,importF60"
shoud be
Code:
ExSh = ",importF48,importF56,importF60,"
 
Upvote 0
I copied this code in the empty "ThisWorkbook".

Option Explicit
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ExSh As String
Set Sh = ActiveSheet
ExSh = ",importF48,importF56,importF60," ' list of sheets with "paste" is disable. Add more. Or change it to actual sheet name
If ExSh Like "*," & Sh.Name & ",*" Then
Sh.Range("A1").Copy
Application.CutCopyMode = False
End If
End Sub


When running the workbook, I can still paste into the import sheets.
In your previous answer you wrote : Note : After sheet_activate, Copy and Paste within sheet is active .
Only copy should be active. Paste should be disabled for these sheets.
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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