Restrict copy/paste to "as values" on certain sheets?

SURFER349

Board Regular
Joined
Feb 22, 2017
Messages
50
So I found this bit of code but it seems to be global and then it 'activates' on a single click rather than the Cntrl+V command.
Any tips on how to simply restrict copy/paste when the user issues the Control+V command?

VBA Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    On Error Resume Next
    Target.PasteSpecial xlPasteValues
    Application.CutCopyMode = True
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Place in ThisWorkbook code window (not a module or sheet)
List sheets names separated by commas
Rich (BB code):
    Dim last As String
    last = Application.CommandBars("Standard").Controls("&Undo").List(1)
    If Left(last, 5) = "Paste" Then
        Select Case Sh.Name
            Case "Pears and Apples", "Oranges and Lemons"
                Application.EnableEvents = False
                Target.PasteSpecial xlPasteValues
                Application.EnableEvents = True
        End Select
    End If
End Sub
 
Upvote 0
I
Place in ThisWorkbook code window (not a module or sheet)
List sheets names separated by commas
Rich (BB code):
    Dim last As String
    last = Application.CommandBars("Standard").Controls("&Undo").List(1)
    If Left(last, 5) = "Paste" Then
        Select Case Sh.Name
            Case "Pears and Apples", "Oranges and Lemons"
                Application.EnableEvents = False
                Target.PasteSpecial xlPasteValues
                Application.EnableEvents = True
        End Select
    End If
End Sub
placed into "ThisWorkbook" but it does not block formatting. I changed the fruit sheets to my specific sheet names but no dice.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,019
Members
448,938
Latest member
Aaliya13

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