Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Sep 2001
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Quick Delete (Excel 97)

    How can I just quickly delete all odd rows?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Quick Delete (Excel 97)

    You cannot just quickly delet all odd rows. As soon as you delete the first one, the first even row following it becomes an odd row. If you want to use VBA, you would need to mark the existing odd cells and then run through them again, deleting the ones marked. Try the following <pre>Sub MarkOdd()
    Dim rngRows As Range
    Set rngRows = Range("A1:A100")
    For Each Cell In rngRows
    If Cell.Row Mod 2 = 1 Then
    Cell.Value = "Del"
    End If
    Next
    For Each Cell In rngRows
    If Cell.Value = "Del" Then
    Cell.EntireRow.Delete
    End If
    Next
    End Sub</pre>

    The above deletes all odd rows in the range A1:A100

    Andrew C

  3. #3
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Quick Delete (Excel 97)

    Ximon

    In a column use this formula and fill it down as many rows as you have data.

    =IF(MOD(ROW(),2)<>0,1/0,"")

    For each row this formula will place a #DIV/0! if it is an odd row, and nothing for even.

    Then you can use Goto Special and use Formulas Errors and then you get all the rows selected.

    Then delete...

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  4. #4
    Lounger
    Join Date
    Sep 2001
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quick Delete (Excel 97)

    Thanks so much for the quick response

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quick Delete (Excel 97)

    Here is what I would do something like this:

    <pre>Public Sub DelOdd()
    Dim I As Long
    For I = 65534 To 0 Step -2
    Worksheets("Sheet1").Range("A1").Offset(I, 0).EntireRow.Delete
    Next I
    End Sub
    </pre>

    Legare Coleman

  6. #6
    Lounger
    Join Date
    Sep 2001
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quick Delete (Excel 97)

    Thanks!

Posting Permissions

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