+ Reply to Thread
Results 1 to 6 of 6

Delete the rows if a cell does not contain certain text

  1. #1
    Registered User
    Join Date
    07-28-2016
    Location
    Chatham
    MS-Off Ver
    2016
    Posts
    93

    Delete the rows if a cell does not contain certain text

    I have few hundreds of thousands lines of data. I would like to delete all the lines that do NOT contain a certain set of letters within a cell.

    For example, I have attached a sample sheet and I would like only the lines that contain "ora" (part of the word "orange") to remain. Would deleting/hiding the other lines (e.g. Melon) be possible?

    If not, would there be a formula that I could use in a separate column to indicate the lines I need and just filter them?

    Thank you very much indeed.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    07-28-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    104

    Re: Delete the rows if a cell does not contain certain text

    Add a helper column with the formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Copy that for every row. Sort by column B. Delete everything that is TRUE in the helper column.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,086

    Re: Delete the rows if a cell does not contain certain text

    You can use AutoFilter with the Text filter "Contains" to select rows/cells containing "ora". Select and delete the visible rows. Same for anything else you want to filter/hide.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: Delete the rows if a cell does not contain certain text

    I second TMS's solution, that's what I would suggest.

    Select your data then navigate to
    Ribbon > Data > Filter
    then you can click on the dropdown boxes that appear and filter for text that contains "ora" (or select the values you want to show).

    You can copy a selection in the list with the normal copy and paste functions. It will only copy visible cells.

  5. #5
    Registered User
    Join Date
    07-28-2016
    Location
    Chatham
    MS-Off Ver
    2016
    Posts
    93

    Re: Delete the rows if a cell does not contain certain text

    Both advice are great, thank you very much indeed!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,086

    Re: Delete the rows if a cell does not contain certain text

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA to delete rows if certain text exist in cell & fill with formula
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2016, 05:46 PM
  2. How to delete rows that contain certain text in a cell using a formula
    By panchovilla1221 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-27-2014, 09:00 PM
  3. [SOLVED] Find row cell containing specific text, then delete all rows ABOVE that cell
    By ks100 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 02:02 PM
  4. [SOLVED] delete rows that do not contain the text from a specific cell
    By Vogelmann in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2012, 03:10 AM
  5. Insert/delete rows or unhide/hide if cell Contains Certain text
    By ashhm in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2012, 08:52 AM
  6. [SOLVED] Code to delete rows that do not contain certain text in a cell
    By rwgladwin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-12-2012, 07:45 AM
  7. Replies: 16
    Last Post: 01-19-2012, 08:18 AM

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