+ Reply to Thread
Results 1 to 7 of 7

How to concatenate a range of cells based on another column

  1. #1
    Registered User
    Join Date
    09-12-2022
    Location
    England
    MS-Off Ver
    MS Office Pro Plus 2021
    Posts
    3

    How to concatenate a range of cells based on another column

    Hi

    I have a set of over 20,000 rows of data spread across multiple topics.

    Sample data below

    Topics Datas Merge
    mankind i am me
    mankind I am ok
    mankind I am yours
    mankind today is
    mankind work it out i am meI am okI am yourstoday is
    earth this is great
    earth thanks for all
    earth this is great
    earth
    earth this is great
    people they are what
    people who said that
    people lets do it
    people ok you are right

    So I have 3 columns, Col1 contains topics, Col2 contains respective datas, Col3 is empty

    What I want to accomplish is a formula that will check the range of topics and where the topic ends, it will concatenate all the corresponding data together. In my sample data, where the topic mankind ends, it should combine all the datas above.

    Thanks
    Last edited by sysads; 09-12-2022 at 03:12 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: How to concatenate a range of cells based on another column

    With data beginning in A2:

    =IF(A3<>A2,TEXTJOIN(" ",,IF(A$2:A2=A2,B$2:B2,"")),"")

    see file.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: How to concatenate a range of cells based on another column

    I just noticed a stray zero. Amend to:

    =IF(A3<>A2,TEXTJOIN(" ",TRUE,IF(A$2:A2=A2,B$2:B2&"","")),"")
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-12-2022
    Location
    England
    MS-Off Ver
    MS Office Pro Plus 2021
    Posts
    3

    Re: How to concatenate a range of cells based on another column

    Hi I am getting an error: a value used in the formula is the wrong data type

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,223

    Re: How to concatenate a range of cells based on another column

    Attach a workbook showing the issue.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    09-12-2022
    Location
    England
    MS-Off Ver
    MS Office Pro Plus 2021
    Posts
    3

    Re: How to concatenate a range of cells based on another column

    Hi I noticed the issue occurs when it sees a very long text. if you use below text, you will see the error:

    Short text: Lorem Ipsum has been the industry's standard dummy text ever since the 1500.
    Long text: Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset

    Saw this from excel: If your TEXTJOIN function crosses the limit of 32,767 characters then it will return the ?#VALUE!? error.
    Last edited by sysads; 09-12-2022 at 08:28 AM.

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,594

    Re: How to concatenate a range of cells based on another column

    Perhaps a method of joining text row by row and then selecting only the fully completed text as in:
    1. Column D: =A2<>A3
    2. Column E: =IF(A2=A1,C1&B2,B2)
    3. Column C: =IF(D2,E2,"")
    Note that columns D:E may be moved and/or hidden for aesthetic purposes.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Help with concatenate across a range of cells based on variables
    By billyshears in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-30-2020, 02:52 PM
  2. [SOLVED] Changing color format in cells based on 3 range values in a different column cells.
    By konkonmike in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-08-2019, 08:11 AM
  3. Sum multiple cells in one column based on date range in another column
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-24-2017, 09:19 AM
  4. Replies: 3
    Last Post: 04-18-2016, 12:16 AM
  5. [SOLVED] UDF concatenate randomly chosen cells from range (Horizontal Range)
    By cheesefry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2014, 03:54 AM
  6. Replies: 9
    Last Post: 12-13-2013, 07:40 PM
  7. Concatenate cells in column range if condition is met
    By AlexVen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2013, 03:30 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