+ Reply to Thread
Results 1 to 5 of 5

Combining multiple rows based on a certain word

  1. #1
    Registered User
    Join Date
    01-29-2020
    Location
    pa
    MS-Off Ver
    1910
    Posts
    2

    Post Combining multiple rows based on a certain word

    I have a text document that I had copied into excel to try and manipulate the data. When copying the document into excel as expected it created a row for each line of text i had in my text document. I posted an example of what the text currently looks like in excel. Basically I want to combine all the text that belongs to each of the BEGIN. So for this example i only want to have 3 cells and for the first cell i want it to say ,BEGIN test smith alex smith bob reynolds in cell 1. and then the 2nd cell will have ,BEGIN ron smith bob hill bill reynolds. and so on. I have tried everything I can think of but some reason can not get it combine the way i want it to. I have run out of ideas. Any help is appreciated.

    ,BEGIN
    test smith
    alex smith
    bob reynolds
    ,BEGIN
    ron smith
    bob hill
    bill reynolds
    ,BEGIN
    sponge bob
    patrick star

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Combining multiple rows based on a certain word

    I am not sure what version of excel you are using. I've used TEXTJOIN function for it:

    A
    B
    1
    ,BEGIN ,BEGIN test smith alex smith bob reynolds
    2
    test smith ,BEGIN ron smith bob hill bill reynolds
    3
    alex smith ,BEGIN sponge bob patrick star alex5p
    4
    bob reynolds
    5
    ,BEGIN
    6
    ron smith
    7
    bob hill
    8
    bill reynolds
    9
    ,BEGIN
    10
    sponge bob
    11
    patrick star
    12
    alex5p



    A
    B
    1
    ,BEGIN =TEXTJOIN(" ",1,OFFSET($A$1,((ROW()-1)*4),0,4,1))
    2
    test smith =TEXTJOIN(" ",1,OFFSET($A$1,((ROW()-1)*4),0,4,1))
    3
    alex smith =TEXTJOIN(" ",1,OFFSET($A$1,((ROW()-1)*4),0,4,1))
    4
    bob reynolds =TEXTJOIN(" ",1,OFFSET($A$1,((ROW()-1)*4),0,4,1))
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: Combining multiple rows based on a certain word

    Assuming that data is in column A, beginning in cell A1, then you can use this formula in B1:

    =IF(A1=",BEGIN",A1&" "&A2&" "&A3&" "&A4,"")

    Copy this down as far as you need to.

    Hope this helps.

    Pete

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Combining multiple rows based on a certain word

    Quote Originally Posted by alex5p View Post
    the first cell i want it to say ,BEGIN test smith alex smith bob reynolds in cell 1. and then the 2nd cell will have ,BEGIN ron smith bob hill bill reynolds. and so on
    @Pete - your formula leave empty cells, OP want to result row by row (as I understand from above quote)

  5. #5
    Registered User
    Join Date
    01-29-2020
    Location
    pa
    MS-Off Ver
    1910
    Posts
    2

    Re: Combining multiple rows based on a certain word

    Thanks for your help that worked!

+ 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: 5
    Last Post: 07-31-2018, 01:43 PM
  2. Replies: 4
    Last Post: 05-09-2017, 06:05 AM
  3. VBA - Combining multiple word documents based on file name and preserving format
    By flakjack in forum Word Programming / VBA / Macros
    Replies: 13
    Last Post: 03-06-2017, 05:34 PM
  4. Combining Rows based on Multiple Columns
    By wlavallee in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-16-2016, 12:24 PM
  5. Combining some of the rows Values based on multiple criteria (2)
    By Svenbe in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-18-2014, 08:59 AM
  6. Combining Text from multiple Rows based on Unique ID
    By lee2k60 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 12:11 AM
  7. Combining Multiple Rows into one based on specific column.
    By jfirestone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 11:40 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