title: Excel ListObject Table - Remove filtered / hidden rows from ListObject table
body: <p>I am banging my head to find a way to delete filtered/hidden rows from a ListObject table.</p>
  
  <p>The filtering is not performed trough the code, it's performed by the user using the table header filters. I want to remove the filtered/hidden rows before unlisting the ListObject Table and perform Subtotal operation. If I don't delete the filtered/hidden rows before unlisting the Table, these rows reappear.</p>
  
  <p>Current Code : </p>
  
  <pre><code>Sub SubTotalParClassification(ReportSheetTitle)
  Dim ws As Worksheet
  Dim drng As Range
  
  Endcol = ColCalculationEndIndex
  Set ws = Sheets(ReportSheetTitle)
  
  'CODE TO REMOVE HIDDEN/FILTERED ROWS
  Set lo = ActiveSheet.ListObjects("Entrée")
  For i = 1 To lo.ListRows.Count Step 1
      If Rows(lo.ListRows(i).Range.Row).Hidden = True Then
          lo.ListRows(i).Delete
  Next
  
  ' convert the table back to a range to be able to build subtotal
  ws.ListObjects("Entrée").Unlist
  With ws
      'Select range to Subtotal
      Set drng = .Range(.Cells(REPORTHEADERROW, REPORTSSTARTCOL),     .Cells(EndRow, Endcol))
  
      'apply Excel SubTotal function
      .Cells.RemoveSubtotal
      drng.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(Endcol - 6,   Endcol - 5, Endcol - 4, Endcol - 3, Endcol - 2, Endcol - 1)
       End With
  
  'Update EndRow
  EndRow = ActiveSheet.Cells(Rows.Count, REPORTSSTARTCOL).End(xlUp).Row
  End Sub
  </code></pre>