+ Reply to Thread
Results 1 to 7 of 7

Find Strings that exclude certain words

  1. #1
    Registered User
    Join Date
    04-07-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    6

    Find Strings that exclude certain words

    I would like to find strings that exclude a short list of words - namely the brand names

    So the macro would find anything except: apple, sony, asus and for those string(s) if there's any spaces add an _

    The sample below shows several strings per row. All strings are contained within one cell. For example "Apple tom jones 456 1/12/12" is all contained within cell a1 & "Apple steve smith 525 2/12/12" within a2 etc. Numbers should be excluded from the search.

    Below is the brand name, customer name, area code, date of purchase

    Sample Data:
    Apple tom jones 456 1/12/12
    Apple steve smith 525 2/12/12
    Sony JOE william johnson 262 5/12/12
    Asus Carla Fausto 525 4/12/12

    Desired Output:
    Apple tom_jones 456 1/12/12
    Apple steve_smith 525 2/12/12
    Sony JOE_william_johnson 262 5/12/12
    Asus Carla_Fausto 525 4/12/

    any insight is appreciated thank you!

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Find Strings that exclude certain words

    1. Text to columns..........
    Data -> Text to Columns -> Delimited -> check the space as a delimiter
    ........That should break your data out into 4 columns
    2. Edit/Replace
    Select Column B and edit/replace (CTRL-H) " " for "_"
    Elegant Simplicity............. Not Always

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Find Strings that exclude certain words

    Try this
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-07-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Find Strings that exclude certain words

    sorry i forgot to mention this is a snippet of the issue. there are several other strings like address, customer comments,etc that have their own unique issues to be addressed later where text to columns would cause more problems than it would solve.

  5. #5
    Registered User
    Join Date
    04-07-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Find Strings that exclude certain words

    Quote Originally Posted by jindon View Post
    Try this
    Please Login or Register  to view this content.
    i'm fairly new to vba is there any way you could explain a bit on this (or anyone else perhaps)? the only thing i seem to understand is the do while loop. ive never seen the create object/ .pattern before, very interesting though i might say.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Find Strings that exclude certain words

    Quote Originally Posted by Mac_Ro View Post
    sorry i forgot to mention this is a snippet of the issue. there are several other strings like address, customer comments,etc
    Quote Originally Posted by Mac_Ro View Post
    i'm fairly new to vba is there any way you could explain a bit on this?
    I don't think the code will work for what you have.
    I just wrote the code on the basis of your example data and the result.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Find Strings that exclude certain words

    no comment
    Last edited by snb; 04-16-2013 at 08:58 AM.



+ 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