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