I'm trying to delete the lines of a TEAMS Table when the Value2 of column D does not match a variable department (String). I'm able to detect the rows I want to delete, but the delete method causes a "delete method of range class failed" error.
Here is a simplified code snippet.
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 <> department Then
.EntireRow.Delete
End If
End With
Next i