Paste in "match destination format" macro code

H

Hopelesslylost

Could anybody give me the macro code line to allow me to paste text in the
"match destination format"

In Word it looks like this:

Selection.PasteAndFormat (wdFormatPlainText)

but I can't find anything in Excel.

Thank's a lot in advance!
 
D

Dave Peterson

If you do Paste|special|values, then the formatting won't change.

Or you could paste the formula?

Or you could just assign the value?

range("a1").copy
range("B1").pastespecial paste:=xlpastevalues

or

range("b1").value = range("a1").value

or
range("B1").value = "my text here"
 
H

Hopelesslylost

Thanks for trying to help. I used

ActiveCell.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
 
Joined
Nov 27, 2012
Messages
1
Reaction score
0
I have created this.. Just see if this works for you.

Private Sub Only_PasteValue_Or_Text()
'
'
'Connect to Ctrl+v
'This will Paste with Destination Formats only
'Tested on Excel 2010 not on previous versions.
'
'
On Error Resume Next
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
ActiveCell.PasteSpecial Paste:=xlPasteValues

ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
False

End Sub
 

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

Top