Hi sorry i am new using VBA i created a code to transfer specific colums from one excel sheet to another but the code is not working.
Please anyone help. Below is the code
Sub copycolumns()
Dim lastrow As Long, erow As Long
lastrow = Order.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
Order.Cells(i, 2).Copy
erow = Template.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Order.Paste Destination:=Worksheets("Template").Cells(erow, 1)
Order.Cells(i, 3).Copy
Order.Paste Destination:=Worksheets("Template").Cells(erow, 2)
Order.Cells(i, 4).Copy
Order.Paste Destination:=Worksheets("Template").Cells(erow, 3)
Next i
Application.CutCopyMode = False
Template.Column().AutoFit
Range("A1").Select
End Sub
Please anyone help. Below is the code
Sub copycolumns()
Dim lastrow As Long, erow As Long
lastrow = Order.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
Order.Cells(i, 2).Copy
erow = Template.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Order.Paste Destination:=Worksheets("Template").Cells(erow, 1)
Order.Cells(i, 3).Copy
Order.Paste Destination:=Worksheets("Template").Cells(erow, 2)
Order.Cells(i, 4).Copy
Order.Paste Destination:=Worksheets("Template").Cells(erow, 3)
Next i
Application.CutCopyMode = False
Template.Column().AutoFit
Range("A1").Select
End Sub