Deleting Rows (more complicated)

bigmacneb

Board Regular
Joined
Jul 12, 2005
Messages
93
I have a Macro which runs and essentially pastes data into 150 rows. However this macro is universal and therefore will have varying data between one row and 150 rows. I need a macro to delete the rows from row 150 to a specific row (but this will constantly change depending on which worksheet the macro is being applied to) How can I do this? Thanks all.
 
Assuming you will *always* be using 150 as your last row, I believe this should work?

Code:
Sub test()
Dim FirstRow As Long

FirstRow = Range("A150").End(xlUp).Row + 2

Rows(FirstRow & ":150").Delete

End Sub
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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