loop in macro

Copper Contributor

 

how i transfer data from 1 sheet to another 

 

1 Reply

Try this

 

Sub copy_data()

Windows("Datasheet.xlsx").Activate
Sheets("Dsheet").Select
Range("A1").Select

For i = 2 To 4
Windows("Exportfile.xlsx").Activate
Sheets("ESheet").Select
Cells(i, 2).Select
Selection.Copy
Windows("Datasheet.xlsx").Activate
Sheets("Dsheet").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
ActiveCell.Offset(0, -1).Select
Selection.End(xlDown).Select
Next
Selection.End(xlUp).Select
End Sub