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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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