+ Reply to Thread
Results 1 to 10 of 10

Concatenate in different way based on criteria

  1. #1
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Concatenate in different way based on criteria

    Hi,
    I have data in Column A and Column B
    Column A Contains category like A,A,A,B,B,B,A,A,A,B,B,B,A,A,A
    And Column B Contains Items 1,2,3,1,3,4,4,5,7,5,6,7,8,9,11 (it will not be in ascending or descending order)

    Now I want to result in Column D and Column E
    D3="A"
    D4="B"
    E3="1-5,7-9,11"
    E4 ="1,3-7"
    Attached Files Attached Files
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question

    Hi,

    the easy way is E3 like 1,2,3,4,5,7, …

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Concatenate in different way based on criteria

    Quote Originally Posted by Marc L View Post
    Hi,

    the easy way is E3 like 1,2,3,4,5,7, …
    thanks for your reply
    but I want to show it in a smart way

  4. #4
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Concatenate in different way based on criteria

    You can try this VBA CODE
    Please Login or Register  to view this content.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This function can be called from any cell in a spreadsheet.
    Last edited by saravnepali; 11-28-2019 at 02:22 AM.
    If you think someone helped you, click on the "* Add Reputation" as a way to say thank you.

    If your problem is solved, go to Thread Tools and select Mark This Thread Solved

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Concatenate in different way based on criteria

    @saravnepal
    thanks for your response,
    It is giving correct result the Item Column (Column B) was in ascending orders only
    and also if the number is not continuous like 6, 8 , 11 etc it is giving result 6-6,8-8,11-11 instead of 6,8,11
    any idea

    see the attached file
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Concatenate in different way based on criteria

    Are the category names known in advance? If so, in what cells will they be listed?

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Concatenate in different way based on criteria

    The following code (which figures out the category names on its own) seems longer to me than I envision it should be in my mind's eye; however, it does seem to do what you asked for...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 11-28-2019 at 10:08 PM.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Concatenate in different way based on criteria

    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Concatenate in different way based on criteria

    In Message #7, I gave you a macro that figures the Category names in use by itself and output them all along with their Item numbers. However, I see saravnepal gave you a function (UDF) which, while it didn't do what you wanted, seemed to be the kind of solution you were after (a function rather than a macro). Given that, here is the function (UDF) that I came up with which takes the Category name as its argument (it assumes your data is in Columns A and B which I can modify if you want to physically specify the range) and produces the output you are after...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 11-28-2019 at 11:49 PM.

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Concatenate in different way based on criteria

    Thank you Jindon and Rick Rothstein
    Both are working fine.

+ 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 range based on Criteria
    By erice in forum Excel General
    Replies: 5
    Last Post: 01-12-2019, 09:24 PM
  2. [SOLVED] Concatenate based on one criteria
    By tkbuc in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-28-2017, 08:24 AM
  3. Concatenate based on criteria
    By jonagpa in forum Excel General
    Replies: 10
    Last Post: 01-08-2016, 04:38 PM
  4. Concatenate Based on the Criteria
    By nawas in forum Excel General
    Replies: 1
    Last Post: 08-06-2015, 12:39 PM
  5. [SOLVED] Concatenate based upon criteria
    By ed_han in forum Excel General
    Replies: 8
    Last Post: 04-08-2015, 10:02 AM
  6. Concatenate a range based on Criteria
    By nuruedriss in forum Excel General
    Replies: 1
    Last Post: 11-06-2013, 10:32 AM
  7. 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

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