ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/ Paste Special (https://www.excelbanter.com/excel-programming/335945-copy-paste-special.html)

GettingThere

Copy/ Paste Special
 
This line works for me: rngSource.Copy Destination:=wsTarget.Range("A2")

but I'd like to add: PasteSpecial Paste:=xlFormats, PasteSpecial
Paste:=xlValues

I'm not getting the syntax right. Could someone help me out please?

Also, since the number of rows in my target changes, I would have preferred
to use something like:

rngSource.Copy Destination:=wsTarget.Range("A" & lstRow + 1) but it fails,
even though I know I have defined lstRow.

Thanks in advance!

KL

Copy/ Paste Special
 
Hi,

Try this:

rngSource.Copy
With wsTarget.Range("A" & lstRow + 1).Resize(rngSource.Rows.Count, _
rngSource.Columns.Count)
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With

Regards,
KL


"GettingThere" wrote in message
...
This line works for me: rngSource.Copy Destination:=wsTarget.Range("A2")

but I'd like to add: PasteSpecial Paste:=xlFormats, PasteSpecial
Paste:=xlValues

I'm not getting the syntax right. Could someone help me out please?

Also, since the number of rows in my target changes, I would have
preferred
to use something like:

rngSource.Copy Destination:=wsTarget.Range("A" & lstRow + 1) but it fails,
even though I know I have defined lstRow.

Thanks in advance!




GettingThere

Copy/ Paste Special
 
Very good KL! Thank you.



"KL" wrote:

Hi,

Try this:

rngSource.Copy
With wsTarget.Range("A" & lstRow + 1).Resize(rngSource.Rows.Count, _
rngSource.Columns.Count)
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With

Regards,
KL


"GettingThere" wrote in message
...
This line works for me: rngSource.Copy Destination:=wsTarget.Range("A2")

but I'd like to add: PasteSpecial Paste:=xlFormats, PasteSpecial
Paste:=xlValues

I'm not getting the syntax right. Could someone help me out please?

Also, since the number of rows in my target changes, I would have
preferred
to use something like:

rngSource.Copy Destination:=wsTarget.Range("A" & lstRow + 1) but it fails,
even though I know I have defined lstRow.

Thanks in advance!






All times are GMT +1. The time now is 03:57 PM.

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