• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete Table Rows based on a column/cell value


Hello There,

I have the below sub to which should delete rows based on value match in a table column. It does delete the rows. Could you please assist in correcting the below code or any other VBA Code which could delete rows in a table based on a value matched to a certain column?

Sub DeleteBatchProcessSummary(pTable As ListObject, pBatchNumberValue As String)
  Dim Fnd As Range, rngSearch As Range, TblSearchColumn As String, TblSearchColumnValue As String

  Set Fnd = pTable.ListColumns("Batch Number").DataBodyRange.Find(What:=pBatchNumberValue, LookIn:=xlValues, LookAt:=xlWhole)
  If Not Fnd Is Nothing Then
    Intersect(pTable.ListColumns("Batch Number").DataBodyRange, Fnd.EntireRow).Delete
  End If
End Sub
Thanks & regards,


Thank you mohadin for the correction. It deletes one occurence of the row.

I would like the following:
1. To delete all occurence of the rows which matches the Find criteria
( pTable.ListColumns("Batch Number" = pBatchNumberValue)

Look forward to hearing from you.