+ Reply to Thread
Results 1 to 5 of 5

Combine specific words into a single word only if all are present

  1. #1
    Registered User
    Join Date
    03-22-2022
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Combine specific words into a single word only if all are present

    Hello. I would like to take an array of arguments and generate an output array that will group certain words together ONLY IF all of the words are together. Else, the output would just be the original arguments.

    Ex.
    i want to return "fruit" only if apple, orange, and banana are all present.

    so
    input: apple, orange, banana, grapes
    output: fruit, grapes

    input: apple, banana, grapes
    output: apple, banana, grapes

    However, I also only want it to use each argument only once

    ex.
    fruit = apple, orange, banana
    tree fruit = apple, orange, banana, pineapple

    input: apple, orange, banana, pineapple, grapes
    output: tree fruit, grapes
    NOT fruit, tree fruit, grapes


    Any suggestions?

  2. #2
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Combine specific words into a single word only if all are present

    a few questions
    - do the fruit always come in the same order? e.g. would the input ever be 'orange, banana, apple' and still be replaced with 'fruit'?
    - are they entered into the same cell, or spread across several cells? helpful if you can mock this up an example workbook
    - for the last example, excel would need some logic to determine if the output should be 'tree fruit, grapes' or 'fruit, pineapple, grapes' as both outputs are technically valid
    <<< If you have valued anyone's contributions in this thread, please click * to thank them for their efforts

  3. #3
    Registered User
    Join Date
    03-22-2022
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Combine specific words into a single word only if all are present

    Thank you for the response. I can mock this up when i get to work.

    - the fruit are always in different orders.
    - they are input into different cells, however i can change it to be in the same cell if thatll make it easier.
    - ok ok thank you. I would need logic then because i only ever one each argument to be used once and i want them to be in the output requiring the larger input
    Attached Images Attached Images
    Last edited by blazeman19; 03-23-2022 at 11:27 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Combine specific words into a single word only if all are present

    I can't think of any smart formulas that will do it in one go.

    Attached is a rough-cut approach using lookup tables and helper columns. It can be heavily optimised, especially if you can use Office 365 instead of 2010, but should give some inspiration to a possible solution.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-22-2022
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Combine specific words into a single word only if all are present

    Thank you so much for the reply. I will take a look at it and get my project done. Thank again man i really appreciate it!

+ 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. Replies: 1
    Last Post: 04-15-2021, 12:01 PM
  2. Find / Extract Word & Words after a Specific Word
    By roseuz in forum Excel General
    Replies: 8
    Last Post: 07-05-2017, 01:07 PM
  3. Replies: 1
    Last Post: 02-21-2016, 02:39 AM
  4. Replies: 6
    Last Post: 04-05-2014, 07:17 PM
  5. [SOLVED] Check a Single Cell to See if Any Words from an Array are Present
    By sweetrevelation in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-01-2013, 08:48 PM
  6. Add to a total IF a specific word is present in coloumn C.
    By milesy2000 in forum Excel General
    Replies: 4
    Last Post: 11-25-2010, 09:30 AM
  7. [SOLVED] search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM

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