+ Reply to Thread
Results 1 to 7 of 7

Concatenate based on one criteria

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Concatenate based on one criteria

    Hi everyone,

    I have a customer list that features two columns. Column A contains Customer Numbers. This column can contain duplicates. Column B contains product info. For the duplicate customer numbers, the product information in column B can be different so I want to concatenate the product info into one cell for all duplicate customer numbers. For non-duplicates, I want to leave the product listed as is. I can't figure out a formula to achieve this result. Does anyone have any suggestions?

    Example is attached.
    Attached Files Attached Files

  2. #2
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,135

    Re: Concatenate based on one criteria

    Hi,

    What is the maximum possible occurrence of "Product" outcomes per customer? Is there any upper limit for this?

  3. #3
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Concatenate based on one criteria

    No real limit, but I don't see it exceeding 10

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland... but I could be anywhere in the world
    MS-Off Ver
    Office 365 for PC.
    Posts
    33,858

    Re: Concatenate based on one criteria

    Easy with a UDF.

    Please Login or Register  to view this content.
    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
    [B][I]

    Then use this array formula:

    =concatall(IF($A$2:$A$11=A2,$B$2:$B$11,""),", ")


    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Glenn



  5. #5
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,135

    Re: Concatenate based on one criteria

    Hi,

    See the attached file.

    I've used few helper columns to segregate the unique matches first & then used another formula to consolidate them into one cell (not as neat as Glenn's UDF solution).

    In C2:
    Please Login or Register  to view this content.
    In K2: (array entered - to be confirmed by pressing CTRL+SHIFT+ENTER
    Please Login or Register  to view this content.
    drag the formula in K2 towards the right side columns up until T2 and again drag the whole range downwards to cover the entire data range.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Concatenate based on one criteria

    Thank you both! Very helpful!!!

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland... but I could be anywhere in the world
    MS-Off Ver
    Office 365 for PC.
    Posts
    33,858

    Re: Concatenate based on one criteria

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Concatenate based on criteria
    By jonagpa in forum Excel General
    Replies: 10
    Last Post: 01-08-2016, 04:38 PM
  2. Concatenate Based on the Criteria
    By nawas in forum Excel General
    Replies: 1
    Last Post: 08-06-2015, 12:39 PM
  3. [SOLVED] Concatenate based upon criteria
    By ed_han in forum Excel General
    Replies: 8
    Last Post: 04-08-2015, 10:02 AM
  4. Concatenate cells based on criteria/threshold
    By amartin575 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-19-2015, 12:26 PM
  5. Concatenate a range based on Criteria
    By nuruedriss in forum Excel General
    Replies: 1
    Last Post: 11-06-2013, 10:32 AM
  6. Pls help, can we concatenate text based on some criteria lik SUMIFS
    By Shermin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-22-2013, 04:31 AM
  7. Concatenate Pivot Table fields based on criteria
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2012, 12:52 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