+ Reply to Thread
Results 1 to 9 of 9

How to lookup and replace string

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    How to lookup and replace string

    I have a lookup table with two columns, viz., OLD VALUE and NEW VALUE. In another sheet I have strings populated in one column. If the string contains OLD VALUE from lookup table, then that OLD VALUE should be replace with the NEW VALUE in the string.

    I have demostrated the same using the attached excel.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    112

    Re: How to lookup and replace string

    =IF('lookup table'!B2=0, "This is my " &'lookup table'!A2, "This is my " &'lookup table'!B2)

  3. #3
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: How to lookup and replace string

    no no no you are hardcoding "This is my " in your formula. The formula should search and replace lookup values from string.

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: How to lookup and replace string

    try this one index/match

    replaceoldbynew.xlsx
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  5. #5
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: How to lookup and replace string

    It is close. But it works only in case of exact match. Fails when the text to be replaced is a part of the string.

  6. #6
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: How to lookup and replace string

    you can try to have wild cards for the match()

    =INDEX('lookup table'!$B$2:$B$3,MATCH("*"&'before update'!A2&"*",'lookup table'!$A$2:$A$3,0))

    if this doesn't work put a sample data on how did those values are organized to be more specific.

  7. #7
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: How to lookup and replace string

    Hi I have attached your excel with sample data and the new formula using wildcard. It is still failing to replace.
    Attached Files Attached Files

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: How to lookup and replace string

    maybe this one???

    replace.xlsx

  9. #9
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: How to lookup and replace string

    Bingo! Fantastic! Yes this is what I am looking for.

+ 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