+ Reply to Thread
Results 1 to 6 of 6

Search for specific text in a string and replace

  1. #1
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Search for specific text in a string and replace

    Hello,

    I have a text such as:


    fdfs&s_kwcid
    sfsd&s_kwcid=dfsads
    &dfsdaf&dsafdsf&s_kwcid=
    fdsf&dasfsdf&s_kwcid=dsfasfsdf



    etc.

    What I want to do is search for "&s_kwcid" or anything containing "&s_kwcid" and replace it with blank.

    So above would then read:

    fdfs
    sfsd
    &dfsdaf&dsafdsf
    fdsf&dasfsdf


    I tried =IF(SUM(COUNTIF(E2,{"&s_kwcid*"}))=1,E2,"") but it didn't work.

    I tried auto filtering, and using contains &s_kwcid* but it didn't filter out results, but find &s_kwcid did find results for text anywhere in string, so I know the problem is there.

    Any help would be apprecaited.

    Thanks
    Last edited by VegasL; 12-04-2009 at 04:46 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Search for specific text in a string and replace

    why not just run Edit -> Replace ?

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Search for specific text in a string and replace

    This would be easier with an actual workbook to look at showing before/after examples, people so often say one thing and mean another, often quite different.

    But if you just want to remove all instances of a text string from a worksheet:

    1) Highlight the range of cells to include
    2) Press CTRL-H to open the Search/Replace window
    3) Enter the search string and leave the replace blank
    4) Click on Replace All
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Re: Search for specific text in a string and replace

    Thanks both for trying to help. The reason a search and replace with blank wouldn't work is, it would still leave anything after &s_kwcid still there. But you both gave me an idea.

    I used a simple: IF(SEARCH("s_kwcid*",E2),E2,"") formula, got the results, paste special as values, then did a find and replace with &s_kwcid* then put blank, and got the desired result.

    I had over 22k data points, so I needed to make sure the correct ones were being replaced, hence needed to isolate the ones being fixed with above formula first.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Search for specific text in a string and replace

    The reason a search and replace with blank wouldn't work is, it would still leave anything after &s_kwcid still there
    Remember you can use wildcards in your Edit -> Replace search terms just as you did in your SEARCH string... ie:

    Replace: &s_kwcid*
    With: nothing

  6. #6
    Forum Contributor
    Join Date
    02-10-2007
    MS-Off Ver
    Excel 2010
    Posts
    293

    Re: Search for specific text in a string and replace

    Gotcha. Thanks

+ 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