+ Reply to Thread
Results 1 to 4 of 4

Help me consolidate excel text data

Hybrid View

  1. #1
    Registered User
    Join Date
    12-29-2020
    Location
    Jakarta
    MS-Off Ver
    2013
    Posts
    2

    Help me consolidate excel text data

    How to merge text data if there is same reference value? Prefer the output to be in new worksheet and linked to source (so if the source is changed, the result is automatically change as well)

    Here the example of source, you can see Ord Number for row 3 and 4 are same
    tanya1.png

    And this is the output I expect
    tanya2.png


    Thanks.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Help me consolidate excel text data

    Of course it CAN be done, but WHY would you want to? merging data into one cell will cause knock-on problems when analysing your data later on.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-29-2020
    Location
    Jakarta
    MS-Off Ver
    2013
    Posts
    2

    Re: Help me consolidate excel text data

    I use it to create shipping label
    Last edited by AliGW; 12-29-2020 at 10:41 AM. Reason: PLEASE don't quote unnecessarily!

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

    Re: Help me consolidate excel text data

    One way:

    Public Function ConcatAll(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
       
        Dim DataIndex As Variant
        Dim strResult As String
        
        If IsArray(varData) _
        Or TypeOf varData Is Range _
        Or TypeOf varData Is Collection Then
            
            For Each DataIndex In varData
                If Len(DataIndex) > 0 Then
                     If bUnique = True Then
                          If InStr(1, "||" & strResult & "||", "||" & DataIndex & "||", vbTextCompare) = 0 Then
                           trResult = strResult & "||" & DataIndex
                        End If
                    Else
                        strResult = strResult & "||" & DataIndex
                    End If
                End If
            Next DataIndex
            
            strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
            
        Else
            strResult = varData
        End If
        
        ConcatAll = strResult
        
    End Function
    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)


    Then... In I11, copied across and down:
    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$10)/(($A$2:$A$10<>"")*(COUNTIF($I$10:$I10,$A$2:$A$10)=0)),1)),"")

    and in J11, an array formula, copied down:
    =IF(I11="","",concatall(IF($A$2:$A$10=I11,$C$2:$C$10&" ("&$D$2:$D$10&")",""),CHAR(10)))

    Don't forget to wrap text in column J, or manually set row width to be deep enough.

    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 the curly brackets { } 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




    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

+ 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: 4
    Last Post: 01-16-2014, 05:59 PM
  2. [SOLVED] Consolidate text data from rows into columns
    By joevan1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-29-2013, 01:10 AM
  3. Consolidate text data from multiple tabs into one table
    By neversummer515 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-01-2013, 05:52 PM
  4. Replies: 1
    Last Post: 01-08-2013, 03:47 AM
  5. Replies: 20
    Last Post: 10-19-2012, 04:35 PM
  6. Simple macro to consolidate text data worksheets into a master one. beginner, no clue
    By Mayyalondon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-06-2012, 10:38 AM
  7. Can't consolidate non-data (ie text) cells from worksheets
    By Tim80 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-19-2006, 10:10 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