Select a row and delete all the data below it

Jak

Well-known Member
Joined
Apr 5, 2002
Messages
833
Hi

I need some VB help to do the following.

I need to select a row which will vary each time. After the row is selected I want to delete all the rows below the selected row.

For example if I select row 900, rows 901-65536 would be deleted.

Any help with some VB code to accomplish this would be great.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
try this

Code:
Sub DeleteRemain()
Dim LR As Long, i As Long
Application.ScreenUpdating = False

LR = ActiveSheet.Cells(65536, 5).End(xlUp).Row
SR = ActiveCell.Row + 1
Rows(SR & ":" & LR).Delete
MsgBox "Done"
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Jak

Well-known Member
Joined
Apr 5, 2002
Messages
833
Hi texasalynn

Thanks very much for the quick reply and excellent code. Works a treat, cheers.
 
Upvote 0

Forum statistics

Threads
1,191,400
Messages
5,986,368
Members
440,021
Latest member
Virtual_Candy_84

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
Top