How to test for valid 'Paste:=xlValues' before attempt.

  • Thread starter Thread starter Bassman62
  • Start date Start date
B

Bassman62

I have code that pastes values at the current selection.
This works fine when the 'copy' is within excel.
However, occasionally the source may be from another application in which
case the 'Paste:=xlValues' fails.
Is there a way to test to see if 'Paste:=xlValues' is a valid option before
using it in the following code?
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Thank you.

Dave
 
Bassman62,

I do not know a solution to check if pastevalues is a valid operation,
however I have the following workaround

on error resume next 'If error occurs while pasting special, go to next lin
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

if err.number <> 0 then
'Paste special could not be performed, perform regular paste
Activesheet.paste
end if
 
Dave,

If Application.CutCopyMode = xlCopy Then
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If

HTH,
Bernie
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