Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Deleting rows based on cell value

$
0
0

I am new to macros and I am looking to delete rows containing the text "Not Applicable" in Column D. I have attached my code below. On compiling, I am getting the error "Application or Object Defined Error". Please let me know what's the right way. The first part of the code is a filtering function which was working fine. I am adding this row delete part and thats when the error is coming.

 Sub Advanced_Filtering()
    If Worksheets("Engagement Sheet").Range("B2") = 2 Then
    Range("C2") = Null
    ElseIf Worksheets("Engagement Sheet").Range("B2") = 1 Then
    Range("C2") = 1
    End If
    Range("A7:G1500").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("A1:G2"), CopyToRange:=Sheets("Sheet3").Range("L1:R1")


BeginRow = 5
    EndRow = 120
    ChkCol = 4
    For Rowcnt = EndRow To BeginRow Step -1
        If ThisWorkbook.ActiveSheet.Cells(Rowcnt, ChkCol).Value = "Not Applicable" Then
           ThisWorkbook.ActiveSheet.Cells(Rowcnt, ChkCol).EntireRow.Delete

        End If
    Next Rowcnt

ActiveSheet.Copy

End Sub

Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>