VBA Code give ERROR 424

Iram

New Member
Joined
May 27, 2020
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
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
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to the Board!

First thing, where are "Order" and "Template" defined?
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

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