Consulting

Results 1 to 11 of 11

Thread: Delete Rows if Cost Code Bucket is Zero

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Jun 2022
    Posts
    16
    Location

    Delete Rows if Cost Code Bucket is Zero

    Hello! I'm trying to write a macro that would eliminate any row if the amount column (D) equals zero. Here is the code I have so far. When I run it, it eliminates some of the rows but not all, and also eliminates all of the information in the first 5 rows up top, which I do not want it to do. I have attached a test file showing all information and the uploaded macro. Thank you so much for your time and effort helping me with this!

    Sub ZeroOutRowsWhenAmountisZero()
    ' ZeroOutEmptyCostCodesButton Macro
    Dim i As Long
        Dim arr As Variant
    Set DataSheet = Sheets("Job Estimate Import")
        With DataSheet
       arr = .Range("D8:D" & FindLastRow(DataSheet, "D"))
          For i = 1 To UBound(arr)
          'Debug.Print arr (i,1)
             If arr(i, 1) = "0" Then
               Rows(i).EntireRow.Delete
            End If
       Next
    End With
    End Sub
    Attached Files Attached Files
    Last edited by Aussiebear; 09-06-2022 at 03:04 PM. Reason: Added code tags to supplied code

Posting Permissions

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