RESTRICT TO PASTE VALUES ONLY

  • Thread starter Thread starter FARAZ QURESHI
  • Start date Start date
F

FARAZ QURESHI

What would be the appropriate code to restrict the user from using pasting
format. In other words, whenever a user uses Ctrl+V only the values are
pasted.

Thanx in advance.
 
Use Application.OnKey to assign one of your macro's to the shortcut
combination Ctrl-V.

Remember to set it back afterwards, or even if the user deactivates the
workbook (since this can be annoying).
 
Private Sub Worksheet_Change(ByVal Target As Range)
'retain formatting when a cell is copied over
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

Note: works only with with copy/paste, not cut/paste


Gord Dibben MS Excel MVP
 
Is there one for copy/paste?

Gord Dibben said:
Private Sub Worksheet_Change(ByVal Target As Range)
'retain formatting when a cell is copied over
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

Note: works only with with copy/paste, not cut/paste


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top