VBA copy selected rows..

ashkankord

New Member
Joined
May 9, 2013
Messages
6
Hi folks,
I am having some trouble executing some VBA, I am trying to find the last row on sheet one and then select 100 rows from the last row up and copy, however I am getting run time error 1004 application defined or object defined error;
I appreciate some help here;


here is my code:

Sub copyrows()
Dim findlastrow As Integer
Worksheets("sheet1").Select
findlastrow = Range("a1").End(xlDown).Row


Dim y As Integer
y = findlastrow - 100

Rows(findlastrow, y).Select




End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
.
.

Firstly, your findlastrow and y variables should be declared as Long data type. Integer is not comprehensive enough.

Secondly, the line Rows(findlastrow, y).Select is incorrect. It should be something like:

Range(Rows(y), Rows(findlastrow)).Select
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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