I have this VBA code to dynamically delete rows from tables, but i am unable to detect when the filter made by my code returns 0 rows, I would like you to skip the Delete step when this happens, as this would mean that there are no rows to be deleted, however, it is giving me an error in the Delete step, here is my code, i tried using If Not rngFiltro Is Nothing
but it gives me an error, here is my code:
Sub EXC_L(lo As ListObject, ws As Worksheet)
Dim colFornecedor As ListColumn
Dim rngFiltro As Range
With ws
lo.AutoFilter.ShowAllData
Set colFornecedor = lo.ListColumns("Fornecedor")
colFornecedor.Range.AutoFilter Field:=colFornecedor.Index, Criteria1:=""
On Error Resume Next
Set rngFiltro = colFornecedor.DataBodyRange.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rngFiltro Is Nothing Then
rngFiltro.EntireRow.Delete
End If
lo.AutoFilter.ShowAllData
End With
End Sub