How a range copy to row2?

techissue2008

Board Regular
Joined
Jun 13, 2008
Messages
80
Hi

This not works:
Code:
Sheets("Sheet2").Range("A2:A").Value = Sheets("Sheet1").Range("D:D").Value

This works:
Code:
Sheets("Sheet2").Range("A:A").Value = Sheets("Sheet1").Range("D:D").Value

How should I make the range copied to and started from A2?

Thanks
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Mike Blackman

Well-known Member
Joined
Jun 8, 2007
Messages
2,494
HI,

One way is;

Code:
Dim lRow As Long

lRow = Range("D" & Rows.Count).End(xlUp).Row

Sheets("Sheet2").Range("A2:A" & lRow).Value = Sheets("Sheet1").Range("D2:D" & lRow).Value
 

techissue2008

Board Regular
Joined
Jun 13, 2008
Messages
80
Hi

Code:
Dim lRow As Long
lRow = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).row
Sheets("Sheet2").Range("A2:A" & lRow).Value = Sheets("Sheet1").Range("D2:D" & lRow).Value

It has error.
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Sheets("Sheet2").Range("A2:A").Value = Sheets("Sheet1").Range("D:D").Value

That does not work because:
1. you did not specify an End Row in the Sheet2 column A.
2. You were trying to put the ENTIRE column from Sheet1 onto Row2 of shee2.
It won't fit, because from Row2 to the end of sheet2 is 65335 rows,
the entire column from sheet 2 is 65536 rows.

Try

LR = Sheets("Sheet1").Range("D" & Rows.Count).End(xlup).row
Sheets("Sheet1").Range("D1:D" & LR).Copy Sheets("Sheet2").Range("A2")
 

Watch MrExcel Video

Forum statistics

Threads
1,127,768
Messages
5,626,758
Members
416,202
Latest member
donya ba

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
Top