title: Delete Excel Rows if They Do Not Contain a Specific String in a Cell
body: <p>I have an excel file where on the 3d (C) column cells, there is a text. If the cell string <strong>does not</strong> contain : "(DELETED)", I want the entire row to be deleted. I tried the following code and it works but as far as concerned the syntax, it needs to be edited. </p>
  
  <p><img src="https://i.stack.imgur.com/FzDGl.png" alt="Print Screen of the Excel file"></p>
  
  <pre><code>Sub sbDelete_Rows_IF_Cell_Contains_Specific_String()
   Dim lRow As Long
   Dim iCntr As Long
   lRow = 5
    For iCntr = lRow To 1 Step -1
      celltxt = Cells(iCntr, 3).Value
      If InStr(1, celltxt, "(DELETED)") Then
  
      Else
       Rows(iCntr).Delete
      End If
    Next
  End Sub
  </code></pre>
  
  <p>If the script finds the cells that contain the string : "(DELETED)", then the program will not do anything. It will delete the ones that do not contain this string. The syntax is bad and I wonder how I can combine the "InStr" and the "IF NOT" functions. </p>