title: Excel VBA delete row where cell contains search string
body: <p>Trying to loop through a column, searching for "Total" within cells that also contain other text (e.g., "January Total", "Boston Total", "Office Total", "Company ABC Total"), and deleting entire rows where "Total" is found.  Here's what I have (r and rcell are defined as range objects):</p>
  
  <pre><code>Set r = Range(Cells(4, "B"), Cells(LastRow, "B"))
  For Each rcell In r
      If Not Excel.WorksheetFunction.Search("Total", rcell) = "#VALUE!" Then
      Rows(target.Row).Delete
      Else
      'do nothing
      End If
  Next
  </code></pre>
  
  <p>I'm trying to pursue the logic that says, "If the cell doesn't contain 'Total', it will return an error.  So, for all the cells that don't return an error, delete the row."  My syntax is clearly wrong.  I've visited a number of similar questions here on the site and haven't been able to substitute working code.</p>
  
  <p>In standard Excel formulas, this would be an IF(ISERROR(SEARCH(...))...).</p>
  
  <p>Thank you very much for the help.</p>