ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Named range row copy/paste problem (https://www.excelbanter.com/excel-programming/423270-named-range-row-copy-paste-problem.html)

John

Named range row copy/paste problem
 
The last line of this code, the paste line, errors out. Both named ranges are
identically formated cols B-H on two different sheets, but the ranges have
different numbers of rows. I'm trying to a copy a selected row from
NamedRange1 to the second row of NamedRange2.
Application.CutCopyMode = False
Sheets("Sheet1").Range("NamedRange1").Rows(j).Copy
Sheets("Sheet2").Select
Sheets("Sheet2").Range("NamedRange2").Rows(2).Past e
I appreciate your help, -John


JLGWhiz

Named range row copy/paste problem
 
You do not need to select sheet 2 if you use the direct copy method. This
would normally all be on one line of code. The sibscript line attenuator
makes the two lines below behave as one.

Sheets("Sheet1").Range("NamedRange1").Rows(j).Copy _
Sheets("Sheet2").Range("NamedRange2").Rows(2)

The syntax you were using for Paste will not work with the Rows collection
object.
You would have to use PasteSpecial with arguments to make it work that way.

"John" wrote:

The last line of this code, the paste line, errors out. Both named ranges are
identically formated cols B-H on two different sheets, but the ranges have
different numbers of rows. I'm trying to a copy a selected row from
NamedRange1 to the second row of NamedRange2.
Application.CutCopyMode = False
Sheets("Sheet1").Range("NamedRange1").Rows(j).Copy
Sheets("Sheet2").Select
Sheets("Sheet2").Range("NamedRange2").Rows(2).Past e
I appreciate your help, -John



All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com