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: Selecting Range using End(ToRight)

Sorry,

The top row of X's are supposed to be evenly spaced over the lower row. There are gaps between cells on the first row which limits the End(xlToRight) function
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Re: Selecting Range using End(ToRight)

Could you please post the entire code?
as Post#20 raises yet further questions
 
Last edited by a moderator:
Upvote 0
Re: Selecting Range using End(ToRight)

Hey,

Apologies, I was pulling data from the right sheet but was taking from A3 and going up a row yielding only a copy area of two cells due to layout. I needed to take from A4 (which has many cells with contents adjacent to one another.

I am now getting another error saying that the copy area and the paste area are not the same size and shape. Its sort of a new topic, but here is the full script.


Code:
Set COM = Workbooks("COMM_COMBINED.xls")    Set PA = Workbooks("COMM_PA.xls")
    Set MAIN = Workbooks("COMM_LD_MAIN.xls")

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

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

I think this is the actual dynamic holding up the show.
 
Upvote 0
Re: Selecting Range using End(ToRight)

SBF12345: You have had four concurrent threads dealing with the same topic, two of which were unmistakably duplicates of questions you'd discussed in the others.

Kindly read Mr Excel's policy against having duplicate threads in Rule 12: http://www.mrexcel.com/forum/board-announcements/99490-forum-rules.html
Please also keep closely-related questions in the same thread so people don't waste time working on pieces of the puzzle without its context and, possibly, at cross-purposes.

I have now merged all four threads. There is some overlap in the discussions, but that's the price you'll have to accept; at least now all participants will have a better idea of the context.
 
Upvote 0
Re: Selecting Range using End(ToRight)

Your code works for me.
Do you have any sheet protection, or merged cells?
 
Upvote 0
Re: ERROR: PasteSpecial Method of Range Class Failed

I am still working on this size shape challenge, but I think I am progressing in the right direction.

when I try to run the script the right stuff is pasted in the right location using the:

Code:
COM.Worksheets(G).Cells(2, Columns.Count).End(xlToLeft).Offset(-1, 1).PasteSpecial Paste:=xlPasteValues

BUT...I still receive the error on the above line and the script seems to continue to run beyond the material pasted at the line that it is held up on.

Im confused...ill try to run it line by line
 
Upvote 0

Forum statistics

Threads
1,223,963
Messages
6,175,656
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