# Excel VBA to Delete Only Visible Rows in Table



## jski21 (Jan 5, 2023)

Good day all,

Trying to delete only visible rows in a table once I've filtered out unnecessary data. Using this code but keep getting a "Delete method of Range class failed" error at the Selection.EntireRow.Delete command. Tried a few logical (to me anyway) changes but to no avail:

'Clear unwanted rows
With Sheets("Trial Balance by SubFund").ListObjects("TrialBal")
      Intersect(.DataBodyRange.SpecialCells(xlVisible), .Parent.Range("A:O")).Select
      Selection.EntireRow.Delete
End With


Any guidance would be appreciated. Thanks.


jski


----------



## Sequoyah (Jan 6, 2023)

Hi jski21
try this code:

```
Application.DisplayAlerts = False
Sheets("Trial Balance by SubFund").ListObjects("TrialBal").DataBodyRange.SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
```


----------



## jski21 (Monday at 7:42 AM)

Thanks Sequoyah. That did the  trick!


jski


----------

