+ Reply to Thread
Results 1 to 5 of 5

Delete all rows that dont contain a specific word.

  1. #1
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Delete all rows that dont contain a specific word.

    Hi,

    I have a range of values in Column A (A4:A500) which have hundreds of detailed product descriptions, these descriptions vary but will always contain a keyword. I want to narrow this list down to one or two key products. Is there a way I can delete all rows which don't contain certain keywords. To keep things simple, lets say I wanted to keep all descriptions which contain "apple" or "pear".

    Anyone know how I might do this so I can make it in to a macro. I've tried to use advanced filter but as descriptions vary I can't can't make it filter results which just contain specific words. Help would be much appreicated.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete all rows that dont contain a specific word.

    Do you have a few sample descriptions that you can post here?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    08-04-2011
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Delete all rows that dont contain a specific word.

    Non-macro
    Insert into B4: =IF(OR(ISERROR(FIND("APPLE",UPPER(A4)))=FALSE,ISERROR(FIND("PEAR",UPPER(A4)))=FALSE),TRUE,FALSE)
    *When replacing APPLE and PEAR, insert new keywords in uppercase format
    Copy down
    Filter on TRUE to get rows you want to keep OR filter on FALSE and delete rows you don't want
    Last edited by Dionysos; 03-14-2012 at 10:33 AM.

  4. #4
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Delete all rows that dont contain a specific word.

    An example sheet attached but using VBA code. Cell H1 is used for the name you want to keep. But the code only hides the rows in case you want to search again later something different. Also starts at A4 until a blank cell is found but easily changed in the code to suit your application. And a quick reset button to unhide the rows again.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: Delete all rows that dont contain a specific word.

    Both good solutions, thanks for the response. I'll play around it the IF statements and see how I go. The macro works well but only filters one word at a time, what I'm really looking to do is narrow a long list of products down to a manageable list of 2 or 3.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1