Consulting

Results 1 to 3 of 3

Thread: Solved: How to delete active row and up to a defined row number

  1. #1

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

    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

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by bananatang
    ...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.
    [vba]
    Option Explicit

    Sub exa()

    If ActiveCell.Row >= 3 Then
    Range(Range("A3"), Cells(ActiveCell.Row, 1)).EntireRow.Delete
    End If
    End Sub
    [/vba]
    Hope that helps,

    Mark

  3. #3
    Thank You mark. The code works well.

    Many Thanks

    BT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •