Cut/paste last 36 rows and move to a new worksheet

mnh

New Member
Joined
Mar 22, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello - newbie here. Using VBA, I need to cut the last 36 rows of data and paste them to a new sheet. The actual number of rows will vary each time we use the sheet.

Any help would be greatly appreciated!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi, welcome to the forum,

would this help ?

VBA Code:
Sub remove_rows()

Dim rownums, lastrow As Long

rownums = Application.InputBox("How Many Rows to Delete ?", "Enter No. of Rows to Remove", "0", , , , , 1)
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row  'checks to find last rowcontaining data in ColA.

row_range = "A" & lastrow - rownums + 1 & ":" & "A" & lastrow

Range(row_range).EntireRow.Delete

End Sub
 
Upvote 1
Solution
Great, glad we could be of assistance for you.

Thanks for the feedback.

Rob
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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