Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50123

Delete target row plus trailing empty row

$
0
0
Hello!
I am stuck on a project and I'm in need of a little assistance. I have found and modified some code that allows me to delete a row that contains a cell that has a formula that is no longer needed. What I am trying to do is delete the empty row that immediately follows the targeted row. I am wondering if there is a better, faster approach to what I am trying to do...here is the code. Let me know what you think! Thanks in advance!

Code:

    Dim Last As Long

    With Sheets(1)
    Last = Range("D" & .Rows.Count).End(xlUp).Row

    For Err = Last To 1 Step -1

        If IsError(.Cells(Err, "D")) Then
            If .Cells(Err, "D") = CVErr(xlErrRef) Then
                .Rows(Err).EntireRow.Delete shift:=xlUp
            End If
        End If
 
    Next Err
    End With


Viewing all articles
Browse latest Browse all 50123

Trending Articles