title: Delete Excel Table row using VBA
body: <p>I'm trying to delete the lines of a <code>TEAMS</code> Table when the <code>Value2</code> of column <code>D</code> does not match a variable <code>department</code> (String). I'm able to detect the rows I want to delete, but the delete method causes a "<code>delete method of range class failed</code>" error.</p>
  
  <p>Here is a simplified code snippet.</p>
  
  <pre><code>Dim i As Integer
  For i = 1 To wkbook.Worksheets("T").Range("TEAMS").Rows.Count
    With wkbook.Worksheets("T").Range("TEAMS[D]")(i)
      If .Value2 &lt;&gt; department Then
        .EntireRow.Delete
      End If
    End With
  Next i
  </code></pre>