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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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
Hi texasalynn

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

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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