I'm encountering a compile error using the following code. The error message I'm receiving is: "Compile Error - Expected: End of Statement".
Thank you for taking a look,
John
As far as I can tell, it should work.Compile Error on Paste
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Compile Error on Paste
You do not have the required permissions to view the files attached to this post.
Regards,
John
John
-
- Administrator
- Posts: 78671
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Compile Error on Paste
You're mixing two different operations in one instruction.
You can combine a copy and a normal paste operation in one instruction:
oCurWB.Sheets("Sheet1").Range("A10").CurrentRegion.Offset(1, 0).Copy Destination:=oNewWB.Sheets("Sheet1").Range("A8")
But for Paste Special you need to perform the copy and pastes operation in separate instructions:
oCurWB.Sheets("Sheet1").Range("A10").CurrentRegion.Offset(1, 0).Copy
oNewWB.Sheets("Sheet1").Range("A8").PasteSpecial Paste:=xlPasteValues
(I omitted the other three arguments since you provided the default values)
As you have found out, you can't combine these into one instruction.
You can combine a copy and a normal paste operation in one instruction:
oCurWB.Sheets("Sheet1").Range("A10").CurrentRegion.Offset(1, 0).Copy Destination:=oNewWB.Sheets("Sheet1").Range("A8")
But for Paste Special you need to perform the copy and pastes operation in separate instructions:
oCurWB.Sheets("Sheet1").Range("A10").CurrentRegion.Offset(1, 0).Copy
oNewWB.Sheets("Sheet1").Range("A8").PasteSpecial Paste:=xlPasteValues
(I omitted the other three arguments since you provided the default values)
As you have found out, you can't combine these into one instruction.
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: Compile Error on Paste
Thanks Hans,
I came to that conclusion but needed to hear it from someone else.
Regards,
John
I came to that conclusion but needed to hear it from someone else.
Regards,
John
Regards,
John
John