+ Reply to Thread
Results 1 to 4 of 4

Substitute text in a string if it matches a value in a table

  1. #1
    Registered User
    Join Date
    04-29-2021
    Location
    US East
    MS-Off Ver
    2019
    Posts
    2

    Substitute text in a string if it matches a value in a table

    I would like to look for a string in sheet 1 column A, compare to values to sheet 2 column A. If the value in sheet 2 column A matches any part of the text in sheet 1 column A, replace it with the value from sheet 2 column B.

    Here is example data. I'm not sure how to write a formula to do this. Any thoughts?

    Sheet1:
    Column A
    \\something\something,ABC\FJones,ReadAndExecute, Synchronize
    \\something\something,ABC\RJones,ReadAndExecute, Synchronize
    \\something\something,ABC\ASmith,ReadAndExecute, Synchronize

    Sheet2:
    Column A
    ABC\FJONES
    ABC\RJones
    ABC\ASmith

    Column B
    XYZ\jonesfre
    XYZ\jonesrob
    XYZ\smithann

    Expected result:
    \\something\something,XYZ\jonesfre,ReadAndExecute, Synchronize
    \\something\something,XYZ\jonesrob,ReadAndExecute, Synchronize
    \\something\something,XYZ\smithann,ReadAndExecute, Synchronize
    Attached Files Attached Files
    Last edited by carolinahusker; 04-29-2021 at 02:05 PM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,207

    Re: Substitute text in a string if it matches a value in a table

    Answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.

    =SUBSTITUTE(A2,Sheet2!A2,Sheet2!B2)

    Ensure the Text matches exactly (upper/Lower case)
    Last edited by JohnTopley; 04-29-2021 at 01:58 PM.

  3. #3
    Registered User
    Join Date
    04-29-2021
    Location
    US East
    MS-Off Ver
    2019
    Posts
    2

    Re: Substitute text in a string if it matches a value in a table

    The formula works for the first two rows. Is there a way to do this by range without causing a spill to the next cell? I've modified the user value so that it matches exactly. Thanks!
    Last edited by carolinahusker; 04-29-2021 at 02:15 PM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,207

    Re: Substitute text in a string if it matches a value in a table

    I used a helper column in B to find a match with the value in A

    =SUMPRODUCT((--ISNUMBER(SEARCH(Sheet2!$A$2:$A$4,A2))*(ROW($A$1:$A$3))))

    in C2

    =IFERROR(SUBSTITUTE(A2,INDEX(Sheet2!$A$2:$A$4,B2),VLOOKUP(INDEX(Sheet2!$A$2:$A$4,B2),Sheet2!$A$2:$B$4,2,FALSE)),A2)
    Attached Files Attached Files

+ 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. Substitute final vowel of text string
    By Henry54289 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-28-2020, 06:10 AM
  2. Replies: 2
    Last Post: 09-27-2020, 11:00 PM
  3. [SOLVED] Macro to substitute cells with a certain string with other text
    By tisahardknocklife in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2017, 05:23 AM
  4. [SOLVED] Need help completing a formula to find and substitute a character in a text string...
    By danielneedssomehelp in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-27-2014, 11:32 AM
  5. [SOLVED] Substitute Text String
    By javeds in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-13-2014, 10:34 AM
  6. [SOLVED] VBA - If a value matches a text string then
    By elliotencore in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2013, 02:22 PM
  7. [SOLVED] Substitute a text string with multiple values
    By dihris in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-03-2012, 03:25 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