title: excel Delete rows from table Macro based on criteria
body: <p>My Question: I am trying to delete rows in a table in column <code>AH</code> and Criteria is "Del" so any cell in column <code>AH</code>, I want to delete entire row in that table.</p>
  
  <p>I tried so many different codes and most take forever as I have 10000+ rows to delete. I found this code from a site, but I am getting an error <code>subscript out of range Error9</code> from the <code>If Intersect</code> line:</p>
  
  <pre><code>Private Sub deleteTableRowsBasedOnCriteria(tbl As ListObject, _
                                             columnName As String, _
                                             criteria As String)
  
      Dim x As Long, lastrow As Long, lr As ListRow
      lastrow = tbl.ListRows.Count
      For x = lastrow To 1 Step -1
          Set lr = tbl.ListRows(x)
          If Intersect(lr.Range, tbl.ListColumns(columnName).Range).Value = criteria Then
              'lr.Range.Select
              lr.Delete
          End If
      Next x
  End Sub
  </code></pre>
  
  <p>Then I called the sub as below:</p>
  
  <pre><code>Set tbl = ThisWorkbook.Worksheets("Sheet1").ListObjects("Table4")
  Call deleteTableRowsBasedOnCriteria(tbl, "AH", "Del")
  </code></pre>
  
  <p>Any help would be great. Thank you. </p>