PDA

View Full Version : Solved: How to delete active row and up to a defined row number



bananatang
01-08-2010, 02:19 AM
Hi Folks,

Need a bit of help here please.

I need a bit of code for my macro that will delete rows starting from the active row that the cursor is in and all the above rows up to Row 3.

i.e if i am in active cell A100. I would like the macro to delete from Row 100 to Row 3.

Many Thanks

BT

GTO
01-08-2010, 03:16 AM
...i.e if i am in active cell A100. I would like the macro to delete from Row 100 to Row 3...

Hi BT,

I wasn't sure if that was inclusive of row three. If not, change to A4. Please note the sheet is not qualified, so works against the active sheet.

Option Explicit

Sub exa()

If ActiveCell.Row >= 3 Then
Range(Range("A3"), Cells(ActiveCell.Row, 1)).EntireRow.Delete
End If
End Sub

Hope that helps,

Mark

bananatang
01-08-2010, 05:59 AM
Thank You mark. The code works well.

Many Thanks

BT