PasteSpecial value

A

Atif

Here are two example of Code. Trying to copy Range of cells from SourceWS to
TargetWS.

This code working fine, as I have formula at Source its copy Formul.
vSourceWS.Range("N" & vSourceLastRow).CurrentRegion.Copy vTargetWS.Range("F"
& vTargetLastRow)

I tried to use PasteSpecial in result receiving Syntex Error
vSourceWS.Range("N" & vSourceLastRow).CurrentRegion.Copy _
vTargetWS.Range("F" & vTargetLastRow).PasteSpecial Paste:=xlPasteValues

Whats worng!

Regards
Atif
 
C

Chip Pearson

The following worked for me:

Worksheets("Sheet1").Range("B5").CurrentRegion.Copy
Worksheets("sheet2").Range("C10").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Perhaps the problem is that you have a line continuation character
sequence (<space><underscore>) at then end of the line that ends with
Copy, so the two lines beginning with vSourceWS and VTargetWS are
being combined into a single line of code, and the resulting code is
not syntactically correct. Get rid of the "_" at the end of the line
and you should be all set.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
 
A

Atif

thank you Gary & Chip;

following code worked for me;
vSourceWS.Range("N500:W" & vSourceLastRow + 1).Copy
vTargetWS.Range("F" & vTargetLastRow + 1).PasteSpecial Paste:=xlPasteValues
 

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