Search code examples
vbaexceldelete-rowlistobject

DELETE from ListObject table rows meeting condition using VBA


Is it possible in VBA to DELETE all the rows meeting condition from Excel ListObject table? I am looking for something similar to SQL statement:

DELETE FROM MyListObjectTable WHERE MyColumn='Some Condition'


Solution

  • Try this:

    .- Break the connection,

    .- Sort the ListObject as per condition (Optional just to have the results of the condition in one Range.Area for the deletion),

    .- AutoFilter the ListObject as per condition,

    .- Delete visible rows of the ListObject.DataBodyRange

    .- Clear AutoFilter