Issue with PasteSpecial

Bnygren

Board Regular
Joined
Feb 11, 2004
Messages
94
When I first open my workbook and run a macro with the following syntax I get an error.

"Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats"

However, if I reset the macro after the error the macro runs fine. I am running Excel 2002.

Any advice??

Thanks,

Bob
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
What kind of paste special are you after?

You could just record a marco while you paste special and then intsert the new code.
 
Upvote 0
That's actually what I did to get the original syntax and then cleaned it up.

It's interesting that if I break it up into two statements:
Step 1: Paste Values
Step 2: Paste Formats
it works just fine.

But, as one command it gives occasional errors.

Bob
 
Upvote 0
This is a portion of the code I am currently working with. If anyone can assist I would be greatly appreciative. I need to provide this workbook to folks outside the office and cannot run the risk of it locking up on them.

Worksheets("agm weekly").Select
ActiveSheet.Unprotect
Range("week1").Copy (Range is 2 columns & 10 rows)

Worksheets("agm results").Select
ActiveSheet.Unprotect
Range("a1").Select
ActiveCell.Offset(r, c).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats

The error I receive is "Run Time Error 1004: PasteSpecial Method of Range Class failed"

Thanks,

Bob
 
Upvote 0

Forum statistics

Threads
1,213,486
Messages
6,113,932
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top