+ Reply to Thread
Results 1 to 5 of 5

VBA to delete rows *partial text*

  1. #1
    Registered User
    Join Date
    11-28-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    73

    VBA to delete rows *partial text*

    I have seen a lot of VBA out there for searching a column and deleting rows which are empty, or deleting ones where criteria is not met. I have a slightly different request.

    I would like to do much the same, but have the VBA look at a partial string. I.e, I would like for it to look for "BOB-SMITH" and keep those rows where the criteria is met. However, this database lacks any sort of control, so people may put "BOB-SMITH2". In the event that the script finds "BOB-SMITH2" where the criteria is "BOB-SMITH", then it will trim down "BOB-SMITH2" to match the criteria. I would also prefer that it trims from both directions, if need be. Then, as most instances of a script like this, I would like it to delete rows where the criteria doesn't match/the field is null. Is something like this possible?

    Thanks in advance!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to delete rows *partial text*

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    11-28-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: VBA to delete rows *partial text*

    Quote Originally Posted by xladept View Post
    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    I have attached a workbook. There's a before and after tab. Let me know if you require clarification and thanks for your time.

    EDIT: Would be ideal for it to trim from both directions in case of "bbBOB-SMITHhh"
    Attached Files Attached Files
    Last edited by jsabo; 02-25-2016 at 11:24 AM. Reason: Clarification

  4. #4
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: VBA to delete rows *partial text*

    Here's my effort. It's designed for the workbook you posted, but I've indicated where to make changes if you need to switch names/columns.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to delete rows *partial text*

    I used an input box for the criterion - we can change that:

    Please Login or Register  to view this content.

+ 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. Find and Select Text and Delete partial row
    By heuder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-21-2015, 10:28 AM
  2. [SOLVED] Delete row based on criteria partial text
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-07-2013, 04:36 AM
  3. delete certain rows based on their partial cell content
    By WasWodge in forum Excel General
    Replies: 3
    Last Post: 01-30-2011, 02:37 PM
  4. Delete rows based upon partial string
    By Knawl in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2009, 11:37 PM
  5. Macro to delete rows based on partial text
    By rossi_69 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-09-2009, 06:25 PM
  6. Delete partial text
    By bnl552 in forum Excel General
    Replies: 2
    Last Post: 09-02-2008, 08:20 PM
  7. Delete partial text
    By bnl552 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2008, 03:45 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