and some other stuff…

How To Cook Dog

Delete Row Containing A Word In Excel

March 12th, 2008 by Dee

In the same data set I was working with last week of 1 Million Lines/Records. I needed to delete every row that contained the word PointA. Here is a simple VB Excel Macro that will delete every row containing “PointA” in column A. It could easily be adjusted for any need to delete a row in excel containing a specific word.


 
Sub DeleteRowsCcntainingWord()
    Dim c As Range
    Dim SrchRng
    
    Set SrchRng = ActiveSheet.Range("A1", ActiveSheet.Range("A65536").End(xlUp))
    Do
        Set c = SrchRng.Find("PointA", LookIn:=xlValues)
        If Not c Is Nothing Then c.EntireRow.Delete
     Loop While Not c Is Nothing
End Sub
 
Filed under programming having

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.