+ Reply to Thread
Results 1 to 6 of 6

Merging text from rows

  1. #1
    Registered User
    Join Date
    09-11-2018
    Location
    Perth
    MS-Off Ver
    2010 Professional
    Posts
    3

    Question Merging text from rows

    I'm trying to merge the text in rows that grouped to the previous column so each item number has one row. There are currently multiple rows per item in column b and c number but not consistent. I would like to do this individually for column b and c. File attached.

    Thanks
    Last edited by MRPLOD; 09-11-2018 at 10:43 PM.

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Merging text from rows

    Can you show what you expect the output to look like based on your sample data?

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Merging text from rows

    To merge cells based on conditions, you might have to use VBA to automate the merge cells. Give below code a try.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-11-2018
    Location
    Perth
    MS-Off Ver
    2010 Professional
    Posts
    3

    Re: Merging text from rows

    Ive attached a picture of what I'm trying to achieve. The rows in the red bubbles are those I'm trying to merge (concat?)
    Attached Images Attached Images

  5. #5
    Registered User
    Join Date
    09-11-2018
    Location
    Perth
    MS-Off Ver
    2010 Professional
    Posts
    3

    Re: Merging text from rows

    text to be merged in the red bubbles
    Attached Images Attached Images

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Merging text from rows

    In the attached the following user defined function code is already installed. You'll find it in the VBA editor. Press Alt + F11 it will open. In the left hand pane find this file name. Under that is "Modules". Double click on that. The module will open on the right with this code already pasted in. Close the VBA editor.

    The user defined function is called CONCATALL. It is written by tigeravatar. This is it.

    PHP Code: 
    'tigeravatar ExcelForum
    Public Function ConcatAll(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
    '
    Created by TigerAvatar at www.excelforum.comSeptember 2012
    'Purpose is to concatenate many strings into a single string
    '
    Can be used with arraysrange objects, and collections
        
        Dim DataIndex 
    As Variant    'Used to loop through arrays, range objects, and collections
        Dim strResult As String     '
    Used to build the result string
        
        
    'Test if varData is an Array, Range, or Collection
        If IsArray(varData) _
        Or TypeOf varData Is Range _
        Or TypeOf varData Is Collection Then
            
            '
    Found to be an, array, range object, or collection
            
    'Loop through each item in varData
            For Each DataIndex In varData
                '
    Check if the item isn't empty
                If Len(DataIndex) > 0 Then
                    '
    Found the item isn't empty, check if user specified bUnique as True
                    If bUnique = True Then
                        '
    bUnique is truecheck if the item has been included in the result yet
                        
    If InStr(1"||" strResult "||""||" DataIndex "||"vbTextCompare) = 0 Then
                            
    'Item has not been included in the result, add item to the result
                            strResult = strResult & "||" & DataIndex
                        End If
                    Else
                        '
    bUnique is not trueadd item to the result
                        strResult 
    strResult "||" DataIndex
                    End 
    If
                
    End If
            
    Next DataIndex
            
            
    'Correct strResult to remove beginning delimiter and convert "||" to the specified sDelimiter
            strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
            
        Else
            '
    Found not to be an array, range object, or collection
            
    'Simply set the result = varData
            strResult = varData
        End If
        
        '
    Output result
        ConcatAll 
    strResult
        
    End 
    Function 

    Then in D2 array enter this formula (already done).If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I didn't know what you wanted for text delimiters. I used "_". Change it in the formula to anything you like.
    Attached Files Attached Files
    Dave

+ 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. Center Align text across different rows (alternative to merging)
    By Eliamme in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-11-2017, 07:03 AM
  2. Merging Multiple Rows in a Column without losing text
    By carlc711 in forum Excel General
    Replies: 1
    Last Post: 07-10-2013, 07:05 PM
  3. Merging Rows with multiple selections without deleting text, VBA may be needed
    By carlc711 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2013, 11:41 AM
  4. Merging Text Rows into single Row - separated by row of quaracters or blank
    By designooze in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2013, 04:22 PM
  5. Merging rows of data and insertin rows conditionally
    By classixuk in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-28-2010, 07:02 PM
  6. Merging rows of text into one
    By wolfy in forum Excel General
    Replies: 3
    Last Post: 01-15-2009, 04:31 AM
  7. Merging the correct number of cell rows to fit a string of wrapped text
    By iterature in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2007, 02:15 PM

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