+ Reply to Thread
Results 1 to 6 of 6

vba code to delete rows with string of text found

  1. #1
    Registered User
    Join Date
    09-13-2011
    Location
    NYC
    MS-Off Ver
    Excel 2016
    Posts
    36

    vba code to delete rows with string of text found

    i have a large spreadsheet with certain rows i need to delete if they have certain strings of text. i need coding to delete rows only if they contain any of the various certain strings of text as a whole. i found code that deletes rows if any single word is found, but i need it to find only exact words together (e.g. county of residence, - not just if any of those words are found elsewhere like when "of" is found in "zip code of residence"

    so: i need to delete rows that contain "county or residence" or "age of respondent" or "zip code of employment"

    I also need it to search 2 different columns rather than just one.

    (i think macros would be the easiest solution??)
    any help would be appreciated! thanks!

  2. #2
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: vba code to delete rows with string of text found

    Maybe something like this?
    Please Login or Register  to view this content.
    Last edited by gjlindn; 09-14-2011 at 12:30 AM. Reason: typo
    -Greg If this is helpful, pls click Star icon in lower left corner

  3. #3
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: vba code to delete rows with string of text found

    How about this?
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: vba code to delete rows with string of text found

    If you need to do this an a regular bases then a macor is a good way to go - It also depends on how many rows need to be checked.

    It may alo possible to use formulas, manual sorting and manula deleting

    The early part of thread
    HTML Code: 
    has various methods of using a macro to search for a whole cell content in a single column
    These various methods can be modified to search a 2nd column.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Registered User
    Join Date
    09-13-2011
    Location
    NYC
    MS-Off Ver
    Excel 2016
    Posts
    36

    Re: vba code to delete rows with string of text found

    works! thanks!!

  6. #6
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: vba code to delete rows with string of text found

    Glad I could help If you haven't already, you should also check out the link mudraker posted. It's great to be able to use vba to solve an issue, but with a little bit of formula and native Excel function knowledge you can decide for yourself if vba is appropriate. Have a great day!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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