ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PasteSpecial value (https://www.excelbanter.com/excel-programming/438031-pastespecial-value.html)

Atif

PasteSpecial value
 
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

Gary Keramidas

PasteSpecial value
 
delete the underscore character

--


Gary Keramidas
Excel 2003


"Atif" wrote in message
...
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



Chip Pearson

PasteSpecial value
 


The following worked for me:

Worksheets("Sheet1").Range("B5").CurrentRegion.Cop y
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]





On Tue, 5 Jan 2010 13:53:01 -0800, Atif
wrote:

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


Atif

PasteSpecial value
 
thank you Gary & Chip;

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


"Atif" wrote:

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



All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com