VBA: Change Sheet to VALUES

SteveOranjin

Board Regular
Joined
Dec 18, 2017
Messages
170
Hello,

I can't find anything online/in these forums about how to change the values of a sheet so it only accepts (and or changes) anything that is copied and pasted into the sheet into a "value".

I'd love to either set up a sheet so it:
  • Automatically changes anything that is pasted into it into values only.
  • Changes any value in sheet1 to a "value".

Hope you are well,

Steve
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Add this to your sheet's code. It forces paste special regardless of how you try and paste. There is no undo once run...


Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.CutCopyMode = xlCopy Then
 Application.EnableEvents = False
 Application.Undo
 Target.PasteSpecial Paste:=xlPasteValues
 Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Not sure, but here's a quick solution...

Code:
[TABLE]
<tbody>[TR]
[TD]Private  Sub Worksheet_Change(ByVal Target As Range)[/TD]
[/TR]
[TR]
[TD]'Erik Van Geit[/TD]
[/TR]
[TR]
[TD]'only allow PasteValues[/TD]
[/TR]
[TR]
[TD]If Application.CutCopyMode =  False Then Exit Sub[/TD]
[/TR]
[TR]
[TD]        With Application[/TD]
[/TR]
[TR]
[TD]        .ScreenUpdating = False[/TD]
[/TR]
[TR]
[TD]        .EnableEvents = False[/TD]
[/TR]
[TR]
[TD]        .Undo[/TD]
[/TR]
[TR]
[TD]        Target.PasteSpecial  Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/TD]
[/TR]
[TR]
[TD]        :=False, Transpose:=False[/TD]
[/TR]
[TR]
[TD]        .EnableEvents = True[/TD]
[/TR]
[TR]
[TD]        .ScreenUpdating = True[/TD]
[/TR]
[TR]
[TD]        End With[/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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