how to copy and past row by row to Second sheet

charith

Board Regular
Joined
Jan 3, 2014
Messages
152
hello..

i want to copy data from column 1 in sheet 1 to column 2 in sheet 2.I tried this code, but it didn't work

Sheets(Sheet1).Cells(.Row, 1).value = Sheets(Sheet2).Cells(.Row ,1).value

please help me


<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"> </code></pre>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Here are a couple of options.
For the second macro select the cell on sheet 1 to copy to sheet 2.

Regards,
Howard


Code:
Option Explicit

Sub AllCells()
Dim c As Range
Dim rngA As Range
Dim lr As Long

lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rngA = Range("A1:A" & lr)

For Each c In rngA
   c.Copy Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Next

End Sub




Sub OneCell()
Dim i As Long
i = ActiveCell.Row

  ActiveCell.Copy Sheets("Sheet2").Cells(i, 1)

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,370
Members
449,080
Latest member
Armadillos

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