ERROR:Copy Paste Areas are different

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
Greetings,

Code:
Range("A4:A3").Select        Range(Selection, Selection.End(xlToRight)).Copy
        COM.Worksheets(G).Activate
        Range("A2").Select
        Selection.End(xlToRight).Offset(-1, 1).Select
        Selection.PasteSpecial Paste:=xlPasteValues


I am receiving an error message that is saying the copy range is not able to paste. The area to be copied is a rectangle. I would like the paste range to be a single cell. How to grab only the cell at the offset point?

Thanks!
 
Re: ERROR: PasteSpecial Method of Range Class Failed

Why not show us the entire script. The copy and paste portion at a minimumn.
Code:
Range("A4").Select
        Range(Selection, Selection.End(xlToRight).Offset(-1, 0)).Copy

these are the copy lines...just to clarify I have the offset here too. my intention is to copy a rectangle two rows by the selection end(xltoRight) wide
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Re: ERROR: PasteSpecial Method of Range Class Failed

In your example tell me what exact range you want to copy.
During my test your wanting to copy the entire rows 3 and 4
 
Upvote 0
Re: ERROR: PasteSpecial Method of Range Class Failed

The syntax of your pastespecial line seems correct. The reason it throws an error could be due to the nature of your data layout on either the source or destination worksheets. It's difficult to say the exact cause from the limited information provided.
 
Last edited:
Upvote 0
Re: ERROR: PasteSpecial Method of Range Class Failed

Hi,

The copy and paste lines are shown above....also in response to your post below...I am trying to copy the contents of row 4 that is selected when the end(xltoRight) method is used and then I want to take that width and take all the cells in the corresponding row above (row 3)...their are blank cells in row 3 limited the potential for a selection method to take all the desired cells. I also want to be able to add and subtract columns if necessary in the future.
 
Upvote 0
Selecting Range using End(ToRight)

I am having trouble selecting a range. I would like to select a range that ends up being a rectangle of two rows by a variable number of columns. I am using the End(toRight) method to select the number of columns. I am having trouble selecting the intended range after I define the width of the rectangle. How can I take a single row range and select the entire width and then grab a few rows up or down? In this case I just want to grab one row more (-1). It seems like Offset might be the right method, but Offset just grabs the next cell up. I looked at the object browser options, but didn't see anything that looked like it might fit.

I could conceivably identify the cell this way and then grab the range by two cell points, but it seems sort of lengthy.

Here are the lines that I am working with:

Code:
MAIN.Worksheets("M_" & G).Activate        Range("A3").Select
        Range(Selection, Selection.End(xlToRight)).
 
Last edited by a moderator:
Upvote 0
Re: Selecting Range using End(ToRight)

How about
Code:
Range("A3", Range("A3").End(xlToRight)).Offset(-1).Resize(2).Select
 
Upvote 0
Application Defined or Object Defined Error

I am receiving the application defined or object defined error on the last line of this chunk of code. I want to paste the copied range at the cell range defined in the last line.

Now receiving the Pastespecial of Range Class failed

Whats wrong with my Range Class for this type of Paste method?

Code:
MAIN.Worksheets("M_" & G).Activate        Range("A3").End(xlToRight).Resize(-1, 0).Copy
        COM.Worksheets(G).Range("A2").End(xlToRight).Offset(-1, 1).PasteSpecial Paste:=xlPasteValues
 
Last edited by a moderator:
Upvote 0
You can't use resize like that.

What is
Code:
COM.Worksheets(G)
Also how many columns do you have?
 
Last edited by a moderator:
Upvote 0
Re: Selecting Range using End(ToRight)

Code:
Set COM = Workbooks("COMM_COMBINED.xls")

Code:
For Each Worksheet In PA.Worksheets    
    
    G = ActiveSheet.Name

I use a for each worksheet loop and then define G as the current activesheet

The layout is something like such below...i tried to make a picture of a spreadsheet, but had some trouble uploading it.


X X X X X
X X X X X X X X X X X X X X X X X X X X X X X X

just imagine the X's align like columns and rows
 
Upvote 0

Forum statistics

Threads
1,223,962
Messages
6,175,654
Members
452,664
Latest member
alpserbetli

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