• Delete Rows Macro (2003)

    Author
    Topic
    #451814

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1113253

      Try this:

      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

      This will also delete rows in which column A is blank. If you don’t want that, change

      If Range("A" & r) = 0 Then

      to

      If Range("A" & r) = 0 And Not Range("A1") = "" Then

    Viewing 0 reply threads
    Reply To: Delete Rows Macro (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: