Run-time error '1004' PasteSpecial Method of Range Class Failed

K

Kevin G

Hi,

I have a macro to copy a range from one sheet1 to sheet2. If a chart in
sheet2 is selected I get the following error.
Run-time error '1004' PasteSpecial Method of Range Class Failed

I would like to set up a error handling proceedure to either:
1) Notify user of chart being selected in sheet2 and then Exit Sub
or
2)Deselect chart in sheet2 and continue running macro

Can this be done?

Thanks, Kevin Graham
 
A

acw

Kevin

Activate the range in sheet2 you want to paste the data before doing the pastespecial
Something like
Range("a1:c1").Copy
Sheets("sheet2").Select
Range("a8").Activate
Range("a8").PasteSpecial Paste:=xlPasteValues
or
Range("a1:c1").Copy
Sheets("sheet2").Select
Range("a8").Select
Range("a8").PasteSpecial Paste:=xlPasteValues

Won't matter if the graph on sheet2 is selected or not as it will remove the focus.

Tony
----- Kevin G wrote: -----

Hi,

I have a macro to copy a range from one sheet1 to sheet2. If a chart in
sheet2 is selected I get the following error.
Run-time error '1004' PasteSpecial Method of Range Class Failed

I would like to set up a error handling proceedure to either:
1) Notify user of chart being selected in sheet2 and then Exit Sub
or
2)Deselect chart in sheet2 and continue running macro

Can this be done?

Thanks, Kevin Graham
 

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