title: Excel VBA Delete Rows Based on Cell Value containing Part of a Text
body: <p>I want to delete rows based on cell value that contains the words "upg" or "upgrade" inside the cell. when this word are there, it is not the only words inside the cell. </p>
  
  <p>Here is part of my code, that not deletes anything:</p>
  
  <pre><code>Sub DeleteValues()
  
  
  Dim i As Integer
  Dim MFG_wb As Workbook
  Dim Dep As Integer
  
  
  
  Set MFG_wb = Workbooks.Open _
  ("C:\Users\rosipov\Desktop\eliran\MFG - GSS\MFG Daily\Fast Daily " &amp; Format(Now(), "ddmmyy") &amp; ".xlsx", _
  UpdateLinks:=False, IgnoreReadOnlyRecommended:=True)
  MFG_wb.Sheets("Aleris").Activate
  
  Dep = MFG_wb.Sheets("Aleris").Range("B2").End(xlDown).Row
  
  
  For i = Dep To 2 Step -1
      Cells(i, 2).Select
      If Not (Selection.Value = "&amp; upg &amp;" Or Selection.Value = "*&amp; upgrade &amp;*") Then
          Rows(i).Delete
      End If
  Next i
  
  
  
  End Sub
  </code></pre>
  
  <p>Here is the problem:</p>
  
  <pre><code>For i = Dep To 2 Step -1
      Cells(i, 2).Select
      If Not (Selection.Value = "&amp; upg &amp;" Or Selection.Value = "*&amp; upgrade &amp;*") Then
          Rows(i).Delete
      End If
  Next i
  </code></pre>