+ Reply to Thread
Results 1 to 6 of 6

Substitute function in Excel

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Substitute function in Excel

    I have a formula that needs to be modified to remove spaces if there are any between the words. The target text value is “Almond Papaya Papaya” in column A. There are scenarios where the target value has a single space (Almond Papaya Papaya), double (Almond Papaya Papaya), triple (Almond Papaya Papaya) and no space (AlmondPapayaPapaya).

    I would like this formula to capture those scenarios, and I believe that the Substitute function in Excel is capable of removing these spaces without changing the formula’s output.

    Here is the formula I have:
    =IF(AND(A2="Almond Papaya Papaya",B2="Home"),"Yes",IF(AND(A2=" Almond Papaya Papaya",B2="Key"),"Yes",IF(AND(A2=" Almond Papaya Papaya ",B2="Door"),"Yes","")))

    Thanks for your assistance in advance.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Substitute function in Excel

    Hi and welcome to the forum

    Im not sure if there are any extra spaces in
    single space (Almond Papaya Papaya), double (Almond Papaya Papaya), triple (Almond Papaya Papaya)
    i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Substitute function in Excel

    I think you could use this version

    =IF(AND(SUBSTITUTE(A2," ","")="AlmondPapayaPapaya",OR(B2={"Home","Key","Door"})),"Yes","")
    Audere est facere

  4. #4
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Substitute function in Excel

    FDibbins: Thanks for the reply. I have attached a sample copy of the formula. In the sample file, the formula is returning "Empty cell" for A2, A4 and A5 because of the spaces in these cells. A2 has no spaces (AlmondPapayaPapaya), A4 has double spaces (Almond Papaya Papaya) and A5 has three spaces (Almond Papaya Papaya). The formula is returning empty cell for these cells because it is hard coded for only single space. Substitute function should work what I am looking for.

    Thanks for your help in advance
    Attached Files Attached Files

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Substitute function in Excel

    Did you try the formula I suggested? Of course because you are doing the comparison with spaces removed you could also get a match with an entry like "al Mondpap ayapa paya"

  6. #6
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Substitute function in Excel

    daddylonglegs: Your suggested formula works! Thanks for the solution.

+ 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