Pasting at a different location on another sheet

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
946
Office Version
  1. 2016
Platform
  1. Windows
Hello All
I have:
VBA Code:
Sheets("ABC").Select
Columns("A:B").Copy
Sheets("XYZ"). _
Columns("A:B").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select

This is working, however, I wish to paste in ("A3:B3") instead of Columns ("A:B")
When I try the recorder, I keep getting a warning that the copy area and the paste area are not the same size, which they are not. How can I copy all of A:B and paste in A3:B3 on sheet XYZ?
Thank you
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
How can I copy all of A:B and paste in A3:B3 on sheet XYZ?
You can't. As you have noted, the ranges are not the same size. All of columns A:B contains 1,048,576 rows. If you paste starting in A3 then you only have 1, 048,574 rows to paste into. It doesn't fit.
Presumably you don't mean copy the whole of columns A:B but copy all of A:B down to the bottom of any data? If column A determines the bottom of the data, then try ..

VBA Code:
With Sheets("ABC")
  .Range("A1:B" & .Range("A" & Rows.Count).End(xlUp).Row).Copy
End With
Sheets("XYZ").Range("A3").PasteSpecial Paste:=xlPasteValues

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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