Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2004
    Location
    Essex, England
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete Rows Macro (2003)

    Can anyone help please?
    I would to be able to write a macro that will delete all the rows in a spreadsheet where there is a zero in column A
    Many thanks

    Robert

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete Rows Macro (2003)

    Try this:
    <code>
    Sub DeleteRowsWithZeroI{nColumnA()
    Dim r As Long
    Dim n As Long
    n = Range("A" & Rows.Count).End(xlUp).Row
    For r = n To 1 Step -1
    If Range("A" & r) = 0 Then
    Range("A" & r).EntireRow.Delete
    End If
    Next r
    End Sub
    </code>
    This will also delete rows in which column A is blank. If you don't want that, change
    <code>
    If Range("A" & r) = 0 Then
    </code>
    to
    <code>
    If Range("A" & r) = 0 And Not Range("A1") = "" Then</code>

  3. #3
    Star Lounger
    Join Date
    Mar 2004
    Location
    Essex, England
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Rows Macro (2003)

    Perfect !

    Thanks Hans

Posting Permissions

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