+ Reply to Thread
Results 1 to 5 of 5

Delete data containing certain Text

  1. #1
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Delete data containing certain Text

    I have names in in Col F that I would like to delete containing


    Queens
    East
    North
    Port
    William


    However, when running my code, the rows containing this text is not deleted

    It would be appreciated if someone could assist me






    Please Login or Register  to view this content.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Delete data containing certain Text

    When you say "containing" do you mean the word in question could be anywhere in the string?
    i.e. should both "Queens of the Stone Age" and "Stone Age Queens" get deleted or just the first one because "Queens" is at the start of the string?

    If the former then changing instances of "= 1" in your IF statement to "> 0" should do the trick.

    BSB

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Delete data containing certain Text

    try >0

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Delete data containing certain Text

    Another approach if you have lots of strings that you need to check and act on would be to create a list of the strings and use a helper column in your data with a MATCH function to identify whether the strings appear in the list.

    Then either without VBA (or indeed with VBA) Autofilter your data for the matches, select the filtered rows and delete them.

    OR modify your existing code but use the helper column.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Delete data containing certain Text

    Thanks for your help and input

+ 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. Replies: 0
    Last Post: 10-10-2013, 07:43 AM
  2. [SOLVED] If Or statement to check cell text and delete entire row if text is found
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2013, 11:46 AM
  3. Find the row a specific text is in a data set & delete certain rows
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2013, 03:52 PM
  4. How to delete entire row of data, by type of text?
    By allustrious in forum Excel General
    Replies: 2
    Last Post: 11-09-2012, 10:46 AM
  5. Select & Delete text in TextBox1 also deletes text in TextBox2
    By heinousanus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2006, 08:02 PM
  6. [SOLVED] In a column of text data, how do I delete random cells that have .
    By Minivann in forum Excel General
    Replies: 2
    Last Post: 01-26-2005, 06:06 PM

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