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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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
 
Upvote 0
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.
 
Upvote 0
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")
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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