+ Reply to Thread
Results 1 to 3 of 3

How do I write a macro to delete all rows from the first empty ro.

  1. #1
    Jon M
    Guest

    How do I write a macro to delete all rows from the first empty ro.

    Does anyone know how I could write a macro to delete all rows from the first
    empty row to row 2000 please? If I use the control+shift+down arrow and then
    go down one cell, the macro programmes the precise cell reference -- but this
    changes on datasheets with different amounts of data. HELP PLEASE!!!

  2. #2
    Jim Thomlinson
    Guest

    RE: How do I write a macro to delete all rows from the first empty ro.

    Try this code.

    Sub DeleteTo2000()
    Dim rng As Range
    Dim wks As Worksheet

    Set wks = ActiveSheet
    Set rng = wks.Range("A1").End(xlDown).Offset(1, 0)

    Range(rng, wks.Range("A2000")).EntireRow.Delete

    End Sub

    HTH

    "Jon M" wrote:

    > Does anyone know how I could write a macro to delete all rows from the first
    > empty row to row 2000 please? If I use the control+shift+down arrow and then
    > go down one cell, the macro programmes the precise cell reference -- but this
    > changes on datasheets with different amounts of data. HELP PLEASE!!!


  3. #3
    Tom Ogilvy
    Guest

    Re: How do I write a macro to delete all rows from the first empty ro.

    set rng = Range("A1").End(xldown)(2)
    if rng.row < 2001 then
    rng.resize(2001-rng.row,1).Entirerow.Delete
    End If

    --
    Regards,
    Tom Ogilvy



    "Jon M" <Jon [email protected]> wrote in message
    news:[email protected]...
    > Does anyone know how I could write a macro to delete all rows from the

    first
    > empty row to row 2000 please? If I use the control+shift+down arrow and

    then
    > go down one cell, the macro programmes the precise cell reference -- but

    this
    > changes on datasheets with different amounts of data. HELP PLEASE!!!




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1